Aug 25, 2009

Determine if your site is running under IIS or Casini

For the people who don't know - Casini is the built in Visual Studio server which is by default running when you debug ASP.NET project.
You can use the following to check if the site is running under IIS:

bool isUnderIIS = this.Request.ServerVariables["SERVER_SOFTWARE"].IndexOf("IIS") > -1;

Not the most clever thing I've ever done but seems to be the only way at the moment.
If you know a better way - let us know...

To clarify - IIS will return something like : "Microsoft-IIS/5.1", while Casini will let you bump your head with
string.Empty.
Anyway, this covers my scenarios 100% so I can use it.

No comments: