ASP.NET webservice: one call to my XmlHttp results in a double'd request
i have a very strange problem with my webservice:
its a typical/standard ASP.NET (v4) webservice, beeing called via GET.
everything works fine, but today i did a trace since i set up a customn http-module
in this http-module i p开发者_JS百科ut some logging-calls, in begin/end-request
when viewing the logs, i can see that if my service get called once (by the clients JS-method), actually two request are done to the webservice
(the http-module runs also for standard ASP.NET winform pages, there i do not have this issue - it occurs only in case of calling the webservice)
Does anybody has an idea what could cause this issue?
A redirect might cause this behavior, e.g. to add a slash to the end of a slashless URL. Also, many authentication schemes may require two requests. If I were in your shoes, I'd look at both requests' content and headers to see what's inside.
Also, you might want to run Fiddler (or any other network tracer, like Firebug or IE dev toolbar) on the client to verify that the client is actually making two requests. It could be that where you have your logging code in the HttpModule might be in a place where multiple calls is natural (e.g. once for headers, once for body).
OK, this is not the final solution but a good work around:
the problem is:
in case of a clients JS-call to the webservice module, the functions are executed twice since the module is run two times: one for CurrentHandler==TransferRequestHandler, the second call (in which session-state is available) then is processed by CurrentHandler==Script/ASPX/Handler
i do not know (until now) whats the reason but i solved it simply by returning/not executing my HttpModule-specific stuff on the first run
so, it works OK but i'm still looking for an explanation, why the HttpModule PreExecute/PostExecuteRequestHandler is called twice in case of a WebService-call, while it is not called twice for a single/standard ASP.NET page request
Regards
精彩评论