Should I use ASPX pages in MVC3 ASP.NET in place of view or not? [closed]
I am designing a project in MVC3 ASP.NET. This project is a website. Should I use ASPX pages in place of view (CSHTML) ?
Which one is more efficient way to do view (CSHTML or ASPX) ?
I'am very fresh in MVC3 ASP.NET. Please suggest me.
You are comparing Razor (cshtml) to WebForms (aspx). Both are view engines so one can replace the other.
I find Razor more efficent to work with as it tends to be less markup and it fits nice with HTML. Webforms tends to be alot about tag soup and <%
all over the place.
Here is a comparison from another SO thread:
Webforms:
<% if(someCondition) { %>
<ol>
<% foreach(var item in Model) { %>
<li><%: item.ToString() %></li>
<% } %>
</ol>
<% } %>
Razor equivalent:
@if(someCondition) {
<ol>
@foreach(var item in Model) {
<li>@item.ToString()</li>
}
</ol>
}
You should experiment and read up on both and make your own opinion on which to use.
I'm not sure what you mean. If you mean should you use the Razor View Engine then it's a matter of personal choice.
My preference, however, is to use the Razor View Engine, as I find it more intuitive and to me it seems to be more efficient.
If you actually mean should you create standard aspx pages and ignore the view engines, then the answer is no.
If you are new to Asp.Net MVC3 and not Asp.Net in general I suggest that you complete a tutorial that utalises Razor as its view engine such as the updated Music Store
Then you can make up your mind whether it is more efficient for you to have less code - Razor or familiar code - WebForms view engine.
精彩评论