The difference between a thought & a decision…is an ACTION!

I am in the process of migrating a large number of sites from a Windows 2003 Server to a Windows 2008 R2 Server for a client. When testing the migrated sites I kept getting the all too familiar 'Object reference not set to an instance of an object' exceptions. As the site was in debug mode at this stage I got the full stack trace and was able to pinpoint the problem to the Page.User object being null. Strange as it was working fine on IIS6 so there must be something different in IIS7 that is causing the exception. After some research I discovered an easy fix to the problem which requires you to add an attribute to the modules node in the system.webServer configuration section of your web.config file as follows: [code language="xml"]<modules runAllManagedModulesForAllRequests="true">[/code] Magically the error disappears after adding this. See the 'Tip/Trick: Url Rewriting with ASP.NET' post on Scott Guthries blog for more details on this.

comments powered by Disqus