我将layout.liquid转换为layout.csthml,这样我就可以看到语法突出显示。
那么,如何在OrchardCore主题中的视图(layout.cshtml)中添加局部视图?
我试着把它叫做
<partial name="~/TheExperimentalTheme/Views/_MyPartial.cshtml" />
<partial name="_MyPartial.cshtml" />但不会呈现任何部分。
局部视图的位置在另一个项目中--主题

但是在页面源代码中呈现的仅仅是
<partial name="/TheExperimentalTheme/Views/_MyPartial.cshtml" />整个布局页面都会被渲染,所以不会出现没有找到我的部分的错误。
我试着给你打电话
@await Html.PartialAsync("_MyPartial") 而不是部分标签帮助器,我得到了这个错误
处理请求时发生未处理的异常。InvalidOperationException:找不到分部视图'_MyPartial‘。搜索了以下位置: /Areas/OrchardCore.Cms.Web/Views/TheTheme/Home/_MyPartial.cshtml /Areas/OrchardCore.Cms.Web/Views/TheTheme/Shared/_MyPartial.cshtml /Areas/OrchardCore.Cms.Web/Views/Shared/_MyPartial.cshtml /Areas/TheExperimentalTheme/Views/TheTheme/Home/_MyPartial.cshtml /Areas/TheExperimentalTheme/Views/TheTheme/Shared/_MyPartial.cshtml /Areas/TheExperimentalTheme/Views/Shared/_MyPartial.cshtml /Areas/OrchardCore.Roles/Views/Shared/_MyPartial.cshtml/Areas/OrchardCore.Settings/Views/Shared/_MyPartial.cshtml /Areas/TheTheme/Views/Home/_MyPartial.en-PH.cshtml /Areas/TheTheme/Views/Home/_MyPartial.en.cshtml /区域/主题/视图/主页/_MyPartial.cshtml /Areas/TheTheme/Views/Shared/_MyPartial.en-PH.cshtml /Areas/TheTheme/Views/Shared/_MyPartial.en.cshtml /Areas/TheTheme/Views/Shared/_MyPartial.cshtml /视图/共享/_MyPartial.en-PH.cshtml /Views/Shared/_MyPartial.en.cshtml /Views/Shared/_MyPartial.cshtml /Pages/Shared/_MyPartial.en-PH.cshtml /Pages/Shared/_MyPartial.en.cshtml /Pages/Shared/_MyPartial.cshtml
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.RenderPartialCoreAsync(string partialViewName,对象模型,ViewDataDictionary viewData,TextWriter编写器)
发布于 2021-08-24 06:52:12
我把它放在我的主题项目的共享文件夹下。
https://stackoverflow.com/questions/68902400
复制相似问题