Monday, 22 March 2010
I've used the UrlRewriting.Net module for a couple years now without any problems in Windows XP. I just recently upgraded my home PC to Windows 7 and started developing a new website.
The plan was to rewrite the URLs to something more meaningful using the UrlRewriting.Net module. Everything worked flawlessly in VS 2008, but when I tried running it through IIS7 it was a different story.
When I was accessing a page via its rewritten URL I could no longer access Page.User; it kept returning null. If I hit the page using it's .aspx extension, Page.User was correctly populated. I should also mention that I have a LoginView controller in my Master Page and it suffered from the same symptoms: When accessing via the rewritten url the AnonyousTemplate was always shown; When using .aspx extension it properly shows the LoggedInTemplate.
The solution was to add the below to web.config:
I found this solution thanks to Scott G who talks about using runAllManagedModulesForAllRequests for this purpose.http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx