Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does MVC Razor generate HTML for the template in the view on client side or server side?

I want to understand where the Razor View Engine actually generates the HTML from the templates that we create in the view. For example see the following code snippet,

<ul id="products" >

<% foreach(var p in products) { %>

  <li><%=p.Name%> ($<%=p.Price%>)</li>
<% } %>

</ul>

I wanted to understand if the processing to generate the resultant html will be done in the browser or the web server.

like image 211
Kartik Sehgal Avatar asked Jan 12 '23 11:01

Kartik Sehgal


2 Answers

I want to understand where the Razor View Engine actually generates the HTML from the templates that we create in the view

It happens on the web server. Once the HTML is fully created on the web server, this HTML is sent to the client browser.

like image 200
Darin Dimitrov Avatar answered Jan 19 '23 21:01

Darin Dimitrov


On the web server!

The browser (thus on client side) can only process Javascript. Razor is an engine such as aspx, Php and so on that helps in dynamically generate html from templated views.

like image 26
Charles HETIER Avatar answered Jan 19 '23 22:01

Charles HETIER