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

David Thielen 3,121 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

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,580 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 65,316 Reputation points
    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 Answers by the question author, which helps users to know the answer solved the author's problem.