❔ What is the difference between .cshtml files and .razor files?
I couldn't find a definitive answer about this anywhere. They both use the razor syntax. Are they interchangeable? Are there features that are only available in .cshtml files and not in .razor files and vice versa?
11 Replies
.cshtml is used for MVC apps while .razor is used for Blazor
So are they essentially the same? In the VS template for blazor apps it still mixes .cshtml and .razor files
They're not the same
I think only the hosted Blazor template uses cshtml as well?
razor is the main thing you work with in Blazor
So what's the difference? If they are using two different extensions then there must be some features that are only available in one of the two types of files right?
They're completely different frameworks
Afaik MVC is server rendering while Blazor is either WASM based or streaming server rendering using SignalR
If they are different frameworks then why are they mixed in blazor apps?
because uhhh... I think that specific template hosts a Blazor app inside an MVC app for some reason?
But both of these file types use the same razor syntax? Are their contents the same, just that the extensions are different in different contexts?
They just look kind of similar afaik
granted I'm not the most qualified person to talk about this
as far as i know are they the same syntax but compile to different things
for example, a razor pages (.cshtml) generates the markup in an ExecuteAsync() method, while blazor (.razor) generates the markup into a BuildRenderTree() method
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.