1

I'm in the process of learning ASP.Net MVC and I'm absolutely in love with the seperation of concerns that MVC gives, and the Model/View/Controller theory of development!

However, I'm having post traumatic flashbacks of the old <% %> html! I'm having a hard time getting over how horrible this is to code and debug!

Why on earth did the MS dev's regress back to that style of coding??

It seemed that the ASP.Net controls were a step forward in HTML markup, but obviously I am missing a larger piece of the puzzle.

Could someone help me understand what benefit we gain from the <% %> classic ASP style of markup over the ASP.Net WebForm style?

Thanks

Scottie
  • 11,050
  • 19
  • 68
  • 109

4 Answers4

1

If you don't like this syntax then I suggest you use the Razor view engine (ASP.NET MVC 3) where you use @ instead of <%: %>

My guess as to why they used that same syntax was it was probably less code to write when they were initially developing ASP.NET MVC and a lot of users wouldn't have to learn a new syntax. Now that it has been out awhile they introduced a new syntax with the Razor view engine that is a lot cleaner.

amurra
  • 15,221
  • 4
  • 70
  • 87
1

You can replace it with another ViewEngine, allowing you to be more flexible with the syntax. MVC 3 now comes with Razor as another prepackaged option. To pick the right View Engine for you, check out this video.

Yuriy Faktorovich
  • 67,283
  • 14
  • 105
  • 142
0

I think that the basic thought was that it is OK to have a dynamic markup style for your view if the framework is promoting a good separation of concerns between that view and the underlying data and business logic. In the bad old ASP days, there was nothing enforcing or even promoting such a separation, and as such we ended up with a lot of very, very messy code.

Chris Shain
  • 50,833
  • 6
  • 93
  • 125
0

if you find yourself digressing from the occasional loop, if...then, and object property access in your markup, which should be producing html output only, then you are probably using the wrong tools for the job

a lot of people like the agility scripting like this gives you. its born out of the buzz of ruby on rails. you can make it compile and type-safe and you can step through, so all the advantages of a compiled "code-behind days" language.

as for asp.net/web forms. life-cycle? view state? no thanks!

jenson-button-event
  • 18,101
  • 11
  • 89
  • 155