简体   繁体   中英

Async PartialView in ASP.Net Core

Does ASP.Net Core MVC have a native implementation of async PartialViews? Because for now, I use sending ajax request to controller/action with some parameters, where partial view renders using received parameters by inside method, then converts to html string, which returns as ajax response. Then js script clears the necessary <div> element, and appends html string from ajax response.

No, ASP.NET Core (Razor engine, to be exact) doesn't know how to render dinamically loaded partial views. It only knows how to render ViewResult

If you are looking for a way to render your partial view async, you can use

@Html.PartialAsync("_PartialName")

For more information you can check out this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM