ASP.Net MVC normal
<% --- used to place .net code if else conditions etc --- %>
<% Response.Write(str) %> is equals to <%= str %> // this is kind of a shortcut of Response.Write in MVC
now the problem is to precent plain string to be injected in response. in asp.net mvc3 we used <%= Html.Encode(str) %> to prevent script injection etc.. but in asp.net mvc 4 a new syntax is introduced as shortcut to Response.Write and Html.Encode, <%: str %>
ASP.Net MVC razor
@{ --- place if else conditions multiple lines etc ---}
@--- single line of code--- can also be used as shortcut to Response.Write @str
@{ Html.RenderPartial("view") }///Render Prefix methods will not return anything but void, they directly write to the response stream.
@Html.Partial /// returns htmlstring that can be used to store in some variable to print at some latter point eg:
@{var output = Html.Partial("View",model);} // assign html to variable
@output //send html to response
<% --- used to place .net code if else conditions etc --- %>
<% Response.Write(str) %> is equals to <%= str %> // this is kind of a shortcut of Response.Write in MVC
now the problem is to precent plain string to be injected in response. in asp.net mvc3 we used <%= Html.Encode(str) %> to prevent script injection etc.. but in asp.net mvc 4 a new syntax is introduced as shortcut to Response.Write and Html.Encode, <%: str %>
ASP.Net MVC razor
@{ --- place if else conditions multiple lines etc ---}
@--- single line of code--- can also be used as shortcut to Response.Write @str
@{ Html.RenderPartial("view") }///Render Prefix methods will not return anything but void, they directly write to the response stream.
@Html.Partial /// returns htmlstring that can be used to store in some variable to print at some latter point eg:
@{var output = Html.Partial("View",model);} // assign html to variable
@output //send html to response
No comments:
Post a Comment