【问题标题】:Paths searched for ViewComponent files in RazorPages app?在 RazorPages 应用程序中搜索 ViewComponent 文件的路径?
【发布时间】:2019-11-03 22:03:01
【问题描述】:

.NET Core 3.0 Razorpages 应用程序

ViewComponents 文件夹
- 我的视图组件类在这里。派生自 ViewComponent 并返回

return await Task.FromResult((IViewComponentResult)View("Default"));

页面/组件/MyViewComponent
- Detault.chtml,这是我的视图组件要使用的视图模板

我在 InvokeAsync 中设置了一个断点,我试图在其中返回视图,这就是我得到 404 的时候

路径位置对吗?

【问题讨论】:

    标签: razor-pages


    【解决方案1】:

    页面/组件/MyViewComponent - Detault.html,这是我的视图组件要使用的视图模板

    ViewComponent 的视图部分应该是 Razor 文件,而不是普通的 html 文件。它应该是默认值。cshtml

    参考:https://www.learnrazorpages.com/razor-pages/view-components

    【讨论】:

    • 对不起,我在帖子中输入错误,但我实际上使用的是 default.cshtml
    猜你喜欢
    • 1970-01-01
    • 2017-09-02
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 2014-03-27
    • 1970-01-01
    • 2013-08-08
    相关资源
    最近更新 更多