开发者

Should I use ASPX pages in MVC3 ASP.NET in place of view or not? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago开发者_如何学编程.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜