In my MVC web application, I'm checking Request.IsLocal to see if the application is running on my machine--if it is, I set a Global static variable which tells the rest of my application that I am in 'Debug Mode'.
The problem is, I don't know when to do this check.
I tried to do it in the global.asax.cs file, under Application_Start(), like this:
protected void Application_Start()
isDebug = true;
The incoming request does not match any route
Application_Start() fires when your MVC site's app pool is spun up. It doesn't really know about the "request" object. So even though this is the correct place to set something application-wide, you won't be able to do it with
Request.IsLocal. You'll have to use a different stragegy. @Jason's suggestion of using the machine name is a good option.
If you'd like to check
Request.IsLocal for every request, write a handler for method for Application_BeginRequest in global.asax. See this for more info.