Global.asax not firing for Release build

We had this problem and a missing PrecompiledApp.config file was the solution. Without it global.asax events did not fire under IIS6 using an ISAPI filter and the rewritten.aspx approach documented e.g. on blog.codeville.net. We use msbuild to precompile the site before deploying. We scratched our heads over this one for a couple of hours when … Read more

ASP.NET MVC app custom error pages not displaying in shared hosting environment

I’ve found the solution and it’s incredibly simple. Turns out the problem was actually in IIS7. While debugging this issue in Visual Studio I saw a property of the HttpResponse object that I hadn’t noticed before: public bool TrySkipIisCustomErrors { get; set; } This lead me to my nearest search engine which turned up a … Read more

what is the global.asax Application_Start equivalent when using WAS in IIS7

I believe AppInitialize() is the method you’re looking for. Here’s an article on using it to initialise Castle Windsor in a WAS hosted WCF service: Castle Windsor and non-HTTP Protocol WCF Services The essence of the article is, instead of using Application_Start() which won’t get called in WAS: protected void Application_Start(object sender, EventArgs e) { … Read more

ASP.NET MVC Url Route supporting (dot)

Add a UrlRoutingHandler to the web.config. This requires your url to be a bit more specific however (f.e. /Users/john.lee). This forces every url starting with /Users to be treated as a MVC url: <system.webServer> <handlers> <add name=”UrlRoutingHandler” type=”System.Web.Routing.UrlRoutingHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” path=”/Users/*” verb=”GET”/> </handlers> </system.webServer>

How to handle session end in global.asax?

You can use global.asax’s session end event to remove the unexpectedly disconnected user : void Session_End(Object sender, EventArgs E) { // Clean up session resources } but beware, session doesn’t end when the user closes his browser or his connection lost. It ends when the session timeout reached.

“Could not load type [Namespace].Global” causing me grief

One situation I’ve encountered which caused this problem is when you specify the platform for a build through “Build Configuration”. If you specify x86 as your build platform, visual studio will automatically assign bin/x86/Debug as your output directory for this project. This is perfectly valid for other project types, except for web applications where ASP.NET … Read more

Multiple HttpPost method in Web API controller

You can have multiple actions in a single controller. For that you have to do the following two things. First decorate actions with ActionName attribute like [ActionName(“route”)] public class VTRoutingController : ApiController { [ActionName(“route”)] public MyResult PostRoute(MyRequestTemplate routingRequestTemplate) { return null; } [ActionName(“tspRoute”)] public MyResult PostTSPRoute(MyRequestTemplate routingRequestTemplate) { return null; } } Second define the … Read more