开发者

Is application is runned under IIS or VS web-server

开发者 https://www.devze.com 2023-01-01 23:20 出处:网络
How to determine whether asp.net (mvc2) application is running under IIS (7) or VS internal web-server?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号