What’s the difference between cshtml and html

Asked

Viewed 5,406 times

4

Is there any difference between CSHTML and HTML, mainly in security, performance and application? There is some loss when using HTML on a project ASP MVC, and what are the benefits of using the CSHTML on a project?

1 answer

8


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

Differences of safety, performance and application between the two things is something quite obvious, and if we were to list all the differences, it would give a book. An HTML page, roughly speaking, is just a page with markups (tags) and scripts that only rotate in the client-side (interpreted by the browser), and may also be amended in client-side. CSHTML accepts server-interpreted code (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, mainly, 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 this will depend a lot on your project. If you intend to use CSHTML, you are supposed to have a project that will make good use of this resource. Generally, to choose a programming language and server resources, it is necessary to trace a scope of the project you want to develop. You often choose a cannon to kill a rabbit. The benefits, in my view, are relative, will depend on your project allied to the resources you intend to use in it.

The page at this link it makes a good catch of the subject.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.