Async page load in mvc

2019-09-02 18:52发布

Im mvc application,there is a some view, data of some portion in view is taking time at the server end, so I need to load the other part of the view first and when the process completes the remaining portion will load.

For this I have create a partial view the partial view action is async and returns a task. But in Mvc 5 I cant use await keyword in view. I sesrch for that mvc 6 is fix this issue.

So now I am loading the partial view by using ajax call. But can I do without ajax call. Or with c# async programming feature.

1条回答
神经病院院长
2楼-- · 2019-09-02 19:30

You have to perform async operations in controller in top level action - neither view nor child actions can be asynchronous in versions up to ASP.Net MVC5.

Or wait till MVC6 is ready, or if you case allows that use MVC6 now - vNext.

查看更多
登录 后发表回答