5

I have a large asp.net-mvc web site . I recently upgraded to MVC 4 but one thing i am debating is it worth it to migrate to razor engine. I see there are tools to "auto" upgrade but i am trying to figure out if its worth the migration pain. I have about 100 total view (both regular and partial). If its a code base that i will have to live with for a while, is it worth the effort?

I know this may seem a bit subjective but given the size of my project I was looking for the expected cost of this migration effort versus the expected benefits.

leora
  • 188,729
  • 360
  • 878
  • 1,366
  • It's really not worth it. If you have an existing application, you are introducing new bugs and issues. Especially when it comes to partials. This isn't easy for me to write. I HATE aspx Views. But, faced with similar dilemma a couple years ago, we decided to make all new views RAZOR and sometimes refactor Views that needed heavy re-work. Otherwise, you will find this to be a long painful road leading where the unaccountable costs (introduced bugs) are NOT worth the headache. – Dave Alperovich Aug 21 '13 at 20:53

4 Answers4

5

Unless you have a specific reason, then IMHO no. Razor is a little, tiny bit (~5% according to most sources) slower than WebForms views however this may be old information. At best, they will render exactly the same speed. I have seen nothing to suggest razor is faster at rendering than webforms(ASP.NET MVC 3 Razor performance) and offers absolutely nothing additional that you cannot do with the WebForms markup.

Basically, its a more succinct markup language and can be a quicker to write and looks better than WebForms syntax. Lastly, if you organization has a legacy of writing WebForms code from back in the day, then all of the developers are already familiar with the WebForms syntax. No learning curve.

So - should you rewrite an entire application? No - you gain nothing. Going forward, should you use Razor? Depends, most 'seem' to be moving that way, it does look nicer and keeps the views a little cleaner.

If, however, you do decide to begin to update your views to razor, remember you can do this in steps. The ViewEngine will look for both types of views when determining what view to render. This does not have to be done in one fell swoop, but could be done gradually over time.

PS - This will probably be closed as a subjective question soon.

Community
  • 1
  • 1
Tommy
  • 39,592
  • 10
  • 90
  • 121
0

No, not unless you have a really compelling reason to. The only real difference is the syntax on the views is a bit neater and there is an inherent "cool" factor working with a different view engine.

When razor first came out, we implemented a bit of a mixture, and so we're currently running a site with both razor and webforms views (this was implemented before razor became the default mvc viewengine).

We have written all new views in razor, and left the older views in webforms which we're slowly migrating across. But its for our benefit, not the customers or end users. So to migrate only the views across is a costly, timely affair that serves no real purpose...

If you've layered your app properly, what I would suggest (seriously) if you were looking at undertaking this, is to leave your existing website alone and create a separate stand alone site, using the new mvc infrastructure. There are definite gains from upgrading the site from an mvc 1 or 2 app to a new mvc 5 app.

We're currently doing this at my place of work, as our models, and logic are all in standalone dll' and we have very thin controllers. We're noticing a lot of changes and updates from the new mvc5 features that are now built in. Things like bundling, twitter-bootstrap etc are all things that we can use to ensure benefits that the customer notices.

Its the same old backend, but a shiny new face and thats worth doing.

spaceman
  • 1,628
  • 1
  • 16
  • 19
0

I think your question is answered in past, if your objectives match with new features you should opt for upgrade, like mobile site support and more..

Old Post

this post gives details of MVC4 Release Notes and difference b/w MVC3 and MVC4 this both answer in this post will help you decide.

The MVC 4 improve those features(main points):

  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Recipes to customize code generation
  • Enhanced support for asynchronous methods

For more details on MVC4, you can refer to: http://www.asp.net/mvc/mvc4

Edit: as the question is View specific,

The views works in the same manner in both version without any change,

you can try removing unwanted view engines

protected void Application_Start() 
{ 
    ViewEngines.Engines.Clear(); 
    ViewEngines.Engines.Add(new RazorViewEngine()); 
}

If you want rendering improvement, you must use the Partial View

<div class="news">
    <h3>News</h3>
    @Html.Partila("NewControl", Model.NewsItems)
</div>

Code Part:

public ActionResult News(){
    NewItemViewModel vm = new NewItemViewModel();
    vm.Items = repository.GetNews();
    return PartialView("NewsControl",vm);
}

This will make the normal speed go increase by 10x

make sure the views are not combines and not passing any null models in view.

This should help in the performance issue.

Community
  • 1
  • 1
MarmiK
  • 5,639
  • 6
  • 40
  • 49
  • I am already using asp.net MVC 4 so the question is not "should i upgrade to MVC 4" but just around the view engine – leora Aug 27 '13 at 10:57
0

If you'd ask me, since I've started using Razor, I'd never look back to the regular ASPX view engine. If you want to introduce fresh flavor to your application and the developers don't mind using the new Razor syntax (which is simpler and cleaner), go for it. If everyone is skeptical about that and application is doing well as it is, do not migrate. Since this question is inviting a personal comment, my opinion goes along with this, which (despite the fact Razor now seems to be negligibly slower than the equivalent ASPX) is obviously saying - migrate me, now.

Community
  • 1
  • 1
jwaliszko
  • 16,942
  • 22
  • 92
  • 158