如何在 Blazor 服务器应用程序中使用 cshtml(Razor 页面)

3HM*_*key 8 asp.net asp.net-mvc razor blazor blazor-server-side

well I am pretty new to Blazor. I have been working with NodeJS alot before. For a new use case I wanted to know more about Blazor, so I am currently investigating in that. Well, what am I planning to do? I'd like to test the components that deal with the entity framework including CRUD-operations. For this I had done a few tests in the past. I personally like that process (it is very inovative and effective) to automatically generate "Razor Pages" for CRUD-operations due to a data model and a data provider. Baaaam, it creates you fully working pages like "edit", "delete", "update" and so on. But thats where the problem came up... In terms of content, these pages are perfect. However, they are rendered without any layout or functionality (maybe interpreted wrong?). So I decided to build up a clean and fresh project.

  1. Created a server side blazor app
  2. Created a folder "Test" inside the "Pages" folder
  3. I created a "Razor Component" with some demo content
  4. 在此输入图像描述

  5. Same for "Razor Page" what I like to do because I like to split code and markup + I need it for generating that CRUD stuff later on. But for now, here is just the demo content.

  6. 在此输入图像描述

  7. 项目清单

  8. Finally the rendered part. As you can see, if I access the Test/index (*.razor) everything is rendered fine like menu, layout and as a single page appplication.

  9. 项目清单

  10. And finally here is the output of the "Razor Page" (*.cshtml). Content is just rendered without layout, without CSS, without hyperlink interpretation and so on.

  11. 项目清单

    Do you know what am I doing wrong? I really like to work with these page gernerators. It is amazing and efficient. Maybe you guys have some tips for me.

Thank you really much.

Greetings

Isa*_*aac 8

如何在 Blazor 服务器应用程序中使用 cshtml(Razor 页面)

您无法在 Blazor 应用程序中托管 Razor Pages 应用程序。但是您可以在 Razor Pages 应用程序中托管 Blazor 组件。如果您托管 Blazor 应用程序的应用程序组件,则实际上您在 Razor Pages 应用程序中托管整个 Blazor 应用程序。

  • 经过大量研究后,我承认,如果我相信你的话,就会节省我很多时间。 (3认同)