When is a .cshtml file appropriate in Blazor (server side)?

David Thielen 3,226 Reputation points
2023-03-14T17:49:06.0366667+00:00

The sample app created by Visual Studio for a server side Blazor creates _Host.cshtml and Error.cshtml. Everything else is a .razor file.

So... when, if ever, should we be creating a .cshtml file? And why are these two files cshtml instead of razor?

thanks - dave

Developer technologies | .NET | Blazor
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,596 Reputation points Volunteer Moderator
    2023-03-14T23:16:24.9633333+00:00

    blazor (WASM or server) is a javascript SPA app. It needs a plain html page to host the javascript. With blazor server, a razor page is used to host, and to display server errors (which would require a running blazor app to display a server error).

    like any SPA, you may want non SPA pages, say for a crawler, or non app use.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.