NullReferenceException in PipelineStepManager.ResumeSteps

asp.netiis-7

Since I have changed my hosting to ASP.NET 4.0 Web Form and IIS7 Integrated Mode, my website usually has the below error:

[NullReferenceException: Object reference not set to an instance of an
object.] System.Web.PipelineStepManager.ResumeSteps(Exception
error) +197
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext
context, AsyncCallback cb) +89
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +189

However, the website works fine. How can I fix this problem?

Best Answer

As Gisli Konrao posted, in a comment, it is due to the fact that you have a custom event handler wired up in the ASP.NET MVC 4 application.

In my case, I had:

this.BeginRequest += new EventHandler(MvcApplication_BeginRequest);

After commenting out this statement, the problem was fixed (ASP.NET wires up these events on the background, so just defining it will make it work).