HttpModule.Init - safely add HttpApplication.BeginRequest handler in IIS7 integrated mode

后端 未结 2 599
耶瑟儿~
耶瑟儿~ 2021-01-02 01:42

My question is similar but not identical to:

Why can't my host (softsyshosting.com) support BeginRequest and EndRequest event handlers? (I\'ve also read the mvol

2条回答
  •  没有蜡笔的小新
    2021-01-02 02:23

    Your HttpModule's Init method will get called multiple times by a single web application (whereas Application_Start in your global.asax will only get called once per AppDomain).

    Init is indeed the place to hook onto BeginRequest.

    I have encountered this error as well and it was caused by hooking onto the BeginRequest event more than once. I'm not sure if it is a bug in IIS 7 integrated mode or not...

    When you do app.BeginRequest are you calling context.BeginRequest using the context parameter to your IHttpModule's Init method or are you calling HttpContext.Current.BeginRequest += ...?

提交回复
热议问题