简体   繁体   English

ASP.Net Core 中的异步 PartialView

[英]Async PartialView in ASP.Net Core

Does ASP.Net Core MVC have a native implementation of async PartialViews? ASP.Net Core MVC 是否具有异步 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.因为现在,我使用发送 ajax 请求到带有一些参数的控制器/动作,其中部分视图使用通过内部方法接收的参数呈现,然后转换为 html 字符串,它返回为 Z2705A83A5A0659EDA57Z3 响应。 Then js script clears the necessary <div> element, and appends html string from ajax response.然后 js 脚本清除必要的<div>元素,并从 ajax 响应中附加 html 字符串。

No, ASP.NET Core (Razor engine, to be exact) doesn't know how to render dinamically loaded partial views.不,ASP.NET Core(准确地说是 Razor 引擎)不知道如何渲染动态加载的局部视图。 It only knows how to render ViewResult它只知道如何渲染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有关更多信息,您可以查看此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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