– What is the difference between cshtml and html


Is there any difference between CSHTML and HTML , mainly in security, performance and application? Are there any losses when using HTML in an ASP MVC project, and what are the benefits of using CSHTML in a project?


CSHTML is a file (extension .cshtml, from c-sharp html ) that has HTML tags, but differs from this one in that it contains codes using the Razor syntax, which is a view engine for ASP.NET MVC and WebMatrix applications, and run on the server using the C# language. This extension (.cshtml) only indicates that the file contains Razor syntax in the C# language that will be interpreted by the server, and as in other server-side languages, the return is pure HTML.

Security, performance, and enforcement differences between the two are pretty obvious, and if we were to list all the differences, it would make a book. An HTML page, roughly speaking, is just a page with marks ( tags ) and scripts that only run on the client side (interpreted by the browser), which can be, in the same way, changed on the client side . CSHTML accepts code interpreted by the server (as explained at the beginning). With this basic notion between the two things, it is already possible to have a notion of application, performance and, above all, security.

Regarding using HTML in ASP MVC, it doesn't make much sense. You don't need an advanced environment (ASP MVC) to create simple HTML pages. But that will depend a lot on your project. If you plan to use CSHTML, it is assumed that you have a project that will make good use of this feature. Generally, to choose a programming language and server resources, you must first outline a project scope that you want to develop. You often choose a cannon to kill a rabbit. The benefits, in my opinion, are relative, it will depend on your project allied to the resources you intend to use in it.

The page on this link is a good overview of the subject.

Scroll to Top