当前位置: 动力学知识库 > 问答 > 编程问答 >

asynchronous - 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/actions 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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: