4
How to get c# some IIS information like Version and some settings like Roles and Services.
*Note: My application is not Web.
4
How to get c# some IIS information like Version and some settings like Roles and Services.
*Note: My application is not Web.
3
One of the probably possible ways to do this is through consultations by WMI
. Some information can be seen on the page IIS WMI Provider.
To work with the IIS and WMI, it is necessary to use the classes of namespace MicrosoftIISv2
. There are some examples here.
Note: If you are using IIS 7, you need to enable compatibility with IIS 6 WMI, to power the MicrosoftIISv2
be present.
In that another page shows some examples of how to get information using WMI
(tested on IIS 6 and Windows Server 2003).
I believe it is also possible to get some information with the class Environment
. According to this page, this can also be done using the Request.ServerVariables
, example:
lblServerIP.Text = Request.ServerVariables["LOCAL_ADDR"];
lblMachineName.Text = Environment.MachineName;
lblUserDomainName.Text = Environment.UserDomainName.ToString();
lblUserName.Text = Environment.UserName;
lblOSVersion.Text = Environment.OSVersion.ToString();
lblStartTime.Text = (Environment.TickCount / (1000 * 60 * 60)) + "Hours";
lblNowTime.Text = DateTime.Now.ToLongDateString();
lblIISVersion.Text = Request.ServerVariables["SERVER_SOFTWARE"];
lblIsHTTPS.Text = Request.ServerVariables["HTTPS"];
lblPATHS.Text = Request.ServerVariables["PATH_INFO"];
lblPATHS2.Text = Request.ServerVariables["PATH_TRANSLATED"];
lblPORT.Text = Request.ServerVariables["SERVER_PORT"];
lblSessionID.Text = Session.SessionID;
All variables can be viewed on the page IIS Server Variables.
i n can use the "Request" pq my application n is web.
@psNytrancez I posted the answer aiming at something generic, usually this type of question is for WEB. In any case there is another way with WMI
. Another thing I forgot to put in the answer, is this page of the MSDN. It’s about the API reference section for working with IIS 7.
This API with II7 also falls into the same scenario of the application not being web.
@psNytrancez I think it does work with this on Desktop.
2
Information about your OSI can be obtained using the ADSI provider. The examples are from IIS 6, but there would be no reason not to work in later versions of IIS.
In this article there are examples of how to get some information and even create websites on IIS.
Besides, there is still excellent article that teaches how to get IIS settings by Active Directory.
This article is also a more targeted effort to read IIS settings.
Upovte. If the articles answer the question, I will mark it as an answer! Thank you.
Browser other questions tagged c# iis
You are not signed in. Login or sign up in order to post.
http://stackoverflow.com/questions/446390/how-to-detect-iis-version-using-c
– Jean Gustavo Prates