Last post Jun 09, 2011 12:55 PM by johngrinder
Jun 03, 2011 07:16 PM|johngrinder|LINK
i'm facing a really damn strange problem in my application with its custom httpModule:
- im using a httpModule to manage NHibernate Session stuff (but thats not important here)
- in this httpModule, i have to do some stuff in PreRequestHandlerExecute() and "PostRequestHandlerExecute()"
- to track the internals in both Pre/PosRequestHandlerExecute() functions, i put some loggin into both of them, just to log when they are called (and with which request they are called and so on...)
the problem is following:
- via the log-entries, i can see that the log-messages from within
- but for standard ASP.NET pages, it works OK; both functions are called in the correct order, both are called only once
i tried already digging into the problem a little bit with Fiddler, to check if there may be something wrong with the client-invoked JS-calls to the service, but everything is fine; apart from the problem that
PreRequestHandlerExecute is called twice (when going through WebSetvice) everything works ok.
i used also VS-debugger, and setting a breakpoint into
PreRequestHandlerExecute() shows exactly that: this function is called two times, the only thing changing from call1 to call2 is the keep-alive-parameter plus some other params.
So if i do a simple JS-call to my webservice ala "WebServiceCall('ActionName', 100)" in the HTML-page, the httpModules function
PreRequestHandlerExecute() is run twice. ??
Has anybode experienced same behaviour? Until now, i've absolutely no idea how this comes; via different google-searches i had no luck, too.
Jun 06, 2011 12:10 PM|johngrinder|LINK
A small update since i found out more:
- i read the article, which described that the Init() function of a HttpModule may be called more than one time (due internal ASP.NET pooling for HttpModules)
- but: this is not the case for PreRequestHandlerExecute()
- very interesting is: if the HttpModule gets called for a WebService request, the HttpContext.Current.Session is NULL on the first time (in function PreRequestHandlerExecute), and its not null only (and always) for the second call
- as said: this behaviour only affects when beeing called by the WebService, for standard ASP.NET pages everything is fine & OK
Jun 09, 2011 12:55 PM|johngrinder|LINK
A small update:
- if the httpModule is called by a WebService request, the first run's CurrentHandler is set to TransferRequestHandler; the second call of PreRequestHandlerExecute() then has CurrentHandler set to something with Script/Session/Wrapper/etc.
- what i do now is just skipping the first run of PreReq...Exec() (with a simple return) if CurrentHandler content is "TransferRequestHandler"
- this is a workaround, but not the final solution - especially since this behaviour occurs only for calls from webservices, but not for calls to standard ASP.NET form pages