How to determine whether asp.net (mvc2) application is running under IIS (7) or VS internal web-server?
Clarification why I need this: I'm composing different dependency graph for IoC-container (ninject) that depends on the workaround (develop - when local VS, and pr开发者_开发百科oduction - when IIS)
Or may be another great solution so I can simply differ 3 workarounds: local (VS), test server (IIS) or production server (IIS). How in this case to differ the server? By PC name?
You could look at System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName
to see what process your ASP.NET app is running in.
If you are working with Visual Studio 2010, you can have a specific web.config file for each environment using transformations (and adding a special appSetting for each environment). Check out the following links:
- Configuration-Specific web.config Files
- Web Deployment with VS 2010 and IIS
精彩评论