简体   繁体   中英

Should I be mixing .cshtml files and .razor files in my .NET 6 project?

I'm not trying to specifically create a Blazor Web application, rather I'm rewriting an old ASP.Net Framework application in Razor and the newest .NET (currently .NET 6). I've created a.razor component for my Footer that is going to appear in all of my pages. I'm unable to get it to display, I currently have this:

@section Footer {
    <component type="typeof(NewProject.Pages.Footer)" render-mode="Static"/>
}

But then I have read that.razor files are supposed to be used in Blazor Web applications and they should be used instead of.cshtml files. I'm trying to stick to Razor pages and MVVM instead of MVC, and I'm still very new to both Razor and Blazor, and before I get too much further into this, I would like to know if I should instead create the Footer as a Partial View instead of a Blazor component. These are the files I've created.

文件列表

Microsoft's answer, apparently, is a big yes. The default Blazor project uses cshtml as the foundation for the site, as well as for the scaffolded Identity system, and razor for everything else.

I know you're not planning to use Blazor, but the above indicates to me that they're meant to co-exist.

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