Is there a cost to using server tags in an ASP.NET MVC view? In other words, is the a context switch when you jump out of markup and into a <% %> block and what is the penalty paid in this instance?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no ‘context switch’.
The way the ASP.NET works is the page is precompiled on the server side to executable code. Then, when a request comes, that code is executed and all server tags are replaced with the actual content they would yield in the response. After that the response is sent to the user.
Thus, anything you put as a
<% %>tag is executed on the server, before the HTML is served to the browser.