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

David Thielen 1,426 Reputation points

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

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

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 45,121 Reputation points

    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.