简体   繁体   中英

What is the difference between "razor" and "cshtml" files?

What is the difference between "razor" and "cshtml" files in ASP.NET. Should we use ".razor" file in "razor-components" application instead of ".cshtml"?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

It does seem a little confusing. For Blazor Server, using the .net core 6 blazor template in VS 2022, if I modify the NavMenu with two new items, one points to a.razor page and one points to a.cshtml page. The one that points to a razor page will display inside the existing layout, the other one will not. It will replace everything. Although the.razor page has to have teh @page directive to allow users to navigate to it.

So, at least for Blazor server, razor pages serve multiple purposes

  • Controls that can be used in other pages
  • Pages (must have @page directive) that can be navigated to, and will appear in the existing layout. Basically these are probably just controls

.cshtml

  • Pages that might use controls, or be used by controls if the page is a laoyout

what is the difference between "razor" and "cshtml" file in ASP.NET. Shall we use ".razor" file in "razor-components" application instead of cshtml ?

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