Вопрос

I'm seeing some very strange behaviour when debugging my web application in VS2010 locally. The same user journey/sequence of pages happens in Production.

Debugging, I'm seeing this:

1. request for MyPage.aspx - handled by thread_1
2. (there is something on that page that IIS/ASP.Net doesn't like it seems) I'm slowly removing sections to pin-point exactly but there's
no JS, or anything fancy there just html content, user controls etc.
3. Either way a separate thread_2 to begin processing the Page_Load of my defaultdocument i.e. home.aspx is executed. There is logic in
home.aspx.cs to clear some data.
4. So when thread_1 continues processing, checks against the data above fail, resulting with the user being redirected to an error page.

Can anyone shed any light on why the second thread is created and why it starts to process my default document?

Please note:

  • I've checked the global methods for errors e.g. session_end, app_error etc but nothing.
  • I do intermittently see a 401 error with Failed Request Tracing Logging enabled but I don't understand how that would start the processing of my default home page?
  • just to sanity check, I placed a new doc test.aspx at the beginning of my defaultdocument list in the web.config and it did get called.

It seems as though, something within IIS/ASP.Net is configured to begin processing the default page on an error but this is new behaviour to me?

I've tried researching this but the only thing that seems that it could be related is thread-agility but I'm not too sure..?

Это было полезно?

Решение 2

After removing a lot of content within the faulty MyPage.aspx, I came across the guilty line of code: btnShowPost.ImageUrl = SitePath + "post.png"; (it was never accessed behind an if statement) and therefore the image <asp:Image ID="btnShowPost" runat="server" /> never set the necessary ImageUrl.

Without it, apparently this is standard browser behavior: any img, script, css, etc, with a src= missing, will use the default path as the url. iis will usually redirect to default.aspx (or whatever is the default).

See full explanation on this link

Другие советы

It seems like there are two HTTP requests running concurrently. As each request (generally) executes on its on thread this condition would make sense.

HTTP requests by default do not share state. They operate on different data. For that reason this is not a thread-safety issue.

An exception to this rule is if you explicitly share state e.g. using static variables. You shouldn't do this for various reasons.

To debug the problem launch Fiddler and examine the HTTP request being executed. Also example HttpContext.Current.Request.RawUrl on each of the two concurrent threads.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top