开发者

Why does asp.net mvc controller action get fired multiple times (images etc) if I make it async?

开发者 https://www.devze.com 2023-02-19 13:29 出处:网络
In both contexts, same code, same application , same routes, only controller action differs. context 1:

In both contexts, same code, same application , same routes, only controller action differs.

context 1: synchronous controller - gets called once

    public void Index(string parameters)
    {
          // called only once
    }

context 2: asynchronous controller actions - gets called lots of times

    public void IndexAsync(string parameters)
    {
         //   called many times (per image etc on the page)
    }

    public ActionResult IndexCompleted()
    {
        return null;
    }

my question,

does anyone understand/know why the same routes/开发者_如何学JAVAactions pick up all the extra requests when I make the controller action asynchronous..?

any help would be very much appreciated,

thanks,

J.


Fire up fiddler and see how the image requests are coming across in both cases. If they come up once for the synchronous method and the browser then realizes it can cache this image or not. Are the URL/Parameters combination the same in the async, sync method?

Please post the responses here on what you see with Fiddler if you can. If you download a demo project at http://msdn.microsoft.com/en-us/library/ee728598.aspx does the same thing happen for you there? Im gathering not which makes me think its a caching issue (off the top of my head).

I know you mention 'same routes' above, but same route and parameters in both cases?

0

精彩评论

暂无评论...
验证码 换一张
取 消