Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to access the properties of a virtual directory in IIS 5.1 from a remote system. For example, "ASP.NET version" in "ASP.NET" tab. So, I wrote a code initially to read the properties from my system.

C#
DirectoryEntry w3svc = new DirectoryEntry("IIS://LocalHost/W3SVC/1/ROOT");
foreach (DirectoryEntry site in w3svc.Children)
{
    if (site.Name == "MyVirtualDir")
    {
        foreach (PropertyValueCollection property in site.Properties)
        {
            Console.WriteLine(string.Format("{0}[{1}]", property.PropertyName, property.Value));
        }
    }
}


But, I am not able to read the property. Can someone please give any hint/suggestion?
Posted
Comments
Have you debugged the code? What are the observations?
senproin.k 15-Jan-14 1:39am    
The following was the output. But, I am not able to get the "ASP.NET version" info... :( Should I modify my code?

AccessFlags[513]
DirBrowseFlags[1073741886]
AppIsolated[2]
KeyType[IIsWebVirtualDir]
Path[D:\MyVirtualDir]
AppRoot[/LM/W3SVC/1/Root/MyVirtualDir]
AppFriendlyName[Senproin]
ScriptMaps[System.Object[]]
HttpErrors[System.Object[]]
DefaultDoc[Default.htm,Default.asp,index.htm,iisstart.asp]
AnonymousPasswordSync[True]
CacheISAPI[True]
CGITimeout[300]
AuthFlags[1]
ContentIndexed[True]
AspLogErrorRequests[True]
AspScriptFileCacheSize[250]
AspScriptEngineCacheMax[125]
AspExceptionCatchEnable[True]
AspTrackThreadingModel[False]
AspAllowOutOfProcComponents[True]
AspEnableAspHtmlFallback[False]
AspEnableChunkedEncoding[True]
AspEnableTypelibCache[True]
AspErrorsToNTLog[False]
AspProcessorThreadMax[25]
AspRequestQueueMax[3000]
AspMaxDiskTemplateCacheFiles[1000]
AspAllowSessionState[True]
AspBufferingOn[True]
AspEnableParentPaths[True]
AspSessionTimeout[20]
AspQueueTimeout[-1]
AspCodepage[0]
AspScriptTimeout[90]
AspScriptErrorSentToBrowser[True]
AppAllowDebugging[False]
AppAllowClientDebug[False]
AspKeepSessionIDSecure[False]
AspEnableApplicationRestart[True]
AspQueueConnectionTestTime[3]
AspSessionMax[-1]
AspLCID[2048]
AnonymousUserName[IUSR_INCHOMDP007108]
AnonymousUserPass[xxxxxxxxxxxxx;]
Realm[yyyyyyyyyy.COM]
AspScriptLanguage[VBScript]
AspScriptErrorMessage[An error occurred on the server when processing the URL. Please contact the system administrator.]
AspDiskTemplateCacheDirectory[%windir%\system32\inetsrv\ASP Compiled Templates]
There is an error at the end.

AspScriptErrorMessage[An error occurred on the server when processing the URL. Please contact the system administrator.]
AspDiskTemplateCacheDirectory[%windir%\system32\inetsrv\ASP Compiled Templates]
senproin.k 15-Jan-14 5:19am    
Would that be a problem? Coz, AspDiskTemplateCacheDirectory[], which is displayed after that has value.
I am not sure. Actually I can test this code, but the problem is I have the IIS 7 at my end.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900