runAllManagedModulesForAllRequests=”true”

runAllManagedModulesForAllRequests=”true” was something I added to all my web.config files for ASP.NET MVC when I wanted to run the web app in deployment on my Windows Server 2008 box.

I wanted to have Glimpse configured for the project though, and as this needed the ability to add (another) module in web.config, I decided to figure out why runAllManagedModulesForAllRequests was needed in the first place, understand a bit more about it, and then hopefully fix it properly as it always seemed a bit of a hack.

Thankfully there is some good advice here:

Don’t use runAllManagedModulesForAllRequests=”true” when getting your MVC routing to work

And a hotfix from Microsoft so you do not need to do any hacking with web.config:

http://support.microsoft.com/kb/980368

Edit 21/8/2013

Turns out applying the above fix might cause some issues if you then have a . in a url slug, eg /blog/guide-to-hotels-at-hotels.com

The .com part causes an issue.

The below link to a stackoverflow answer shows how to add a httphandler that solves this problem…

http://stackoverflow.com/a/12151501/5463

ASP.NET MVC RenderSection

This post is as much for my own use as others as I’m always¬†forgetting how to add sections to an asp.net mvc masterpage.

In the master page add your subsection using:

<footer>@RenderSection(“Footer”)</footer>

and in the views implement this section using:

@section Footer {
<p>This is my footer</p>
}

You can make the section optional in your view:

<footer>@RenderSection(“Footer”, required: false)</footer>