HttpModule with ASP.NET MVC not being called

前端 未结 3 938
梦谈多话
梦谈多话 2021-01-11 16:41

I am trying to implement a session-per-request pattern in an ASP.NET MVC 2 Preview 1 application, and I\'ve implemented an IHttpModule to help me do this:

pu         


        
相关标签:
3条回答
  • 2021-01-11 17:07

    You might have to put the Response.Write in the method that subscribes to the EndRequest (or the BeginRequest) event. I'm guessing the Response object hasn't been fully initialized at the Init stage.

    0 讨论(0)
  • 2021-01-11 17:21

    Turns out there's a Web.config file in the Views folder, and one in the root. Guess which one I registered the httpModules in? Yep, the Views folder one. I moved it to the root Web.config and now it works like a charm.

    0 讨论(0)
  • 2021-01-11 17:24

    My problem was that I had [HandleError] on the Controller Method, which was catching the error before my custom error handler had a chance to.

    0 讨论(0)
提交回复
热议问题