asp.net mvc 4 async controller hanging on none TaskAsync methods

后端 未结 1 918
故里飘歌
故里飘歌 2021-01-24 11:34

I\'m using Visual Studio 2011 Beta with 4.5 Beta. There seems to be a bug with ASP.Net MVC 4, where if the method returns a none \"TaskAsync\" task, it hangs the request.

<
相关标签:
1条回答
  • 2021-01-24 12:15

    Known issue with MVC 4 Beta.

    In short, add the following to ~/Web.config:

      <appSettings> 
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
      </appSettings> 
    

    Then add await Task.Yield(); as the first line in your action method. (Don't forget the await!)

    0 讨论(0)
提交回复
热议问题