HttpContext.Current.Request.IsLocal is not available in Global.Asax/Application_Start (Request is not available in the context).
How else could I safely determine if my ASP.NET MVC application is started locally or not?
This is to rewrite my web.config conditionally (depending on whether the application is deployed (remote) or in testing (local)).
Thank you!
The Application_Start event will be fired when IIS/cassini/whatever loads up your app (way before any HTTP requests have been made).
Reading your comments you want this to be a "one time operation" which really makes no sense. Your application is not so much "started locally" but it may be requested locally and/or remotely several times throughout its life cycle. With this in mind you need to check on each request as David commented.
Maybe, it would be better if you explained a little more what you are trying to achieve?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With