Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

How can I know under which IIS version my Asp.Net application is running?


How can I know under which IIS version my web application is running in development server?
As .Net framework 2.0,3.0,3.5,4.0 have support built in IIS....
Thanks

Upvotes: 12

Views: 12742

Answers (5)

Dave
Dave

Reputation: 1961

I saw someone already answered to a degree, but I did want to mention that the best practice is to include your .NET target environment into your ASP.NET application. This way the target environment will be present.

Upvotes: 0

Eric Leschinski
Eric Leschinski

Reputation: 153812

The version number can be queried from the Windows Registry:

On windows, run regedit and navigate to this directory:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\VersionString  

Mine returns Version 6.0 because I am running Windows 2003 Server.

Upvotes: 2

Richard
Richard

Reputation: 108975

This is available directly from the SERVER_SOFTWARE server variable:

HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"];

which is a string like "Microsoft-IIS/7.0".

NB, the string is empty for the ASP.NET development server ("Casini").

Upvotes: 10

Doctor Jones
Doctor Jones

Reputation: 21654

To get the IIS version of the webserver you can use the SERVER_SOFTWARE server variable.

Request.ServerVariables["SERVER_SOFTWARE"];

It will return something like as follows:

Microsoft-IIS/5.0 (Windows 2000)

Microsoft-IIS/5.1 (Windows XP)

Microsoft-IIS/6.0 (Windows 2003 Server)

You can find a full reference of server variables here.

Upvotes: 14

Doctor Jones
Doctor Jones

Reputation: 21654

@AnthonyWJones "So the question becomes, How does an ASP.NET application determine what operating system it is running on?"

You can use System.Environment.OSVersion

Upvotes: 3

Related Questions