开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜