Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading ASP.NET MVC2 project to MVC3 and using mixed View Engines

Can I upgrade my MVC2 project to MVC3 and continue to use my ASPX views, AND at the same time start writing some new views in Razor?

More specifically, Can I take an ASPX view page, and a Razor control in it? Would such a thing be possible?

Any other things one should look out for?

like image 231
taudep Avatar asked Jan 13 '11 18:01

taudep


2 Answers

You can definitely mix view engines across totally separate views. As for putting Razor "controls" in an ASPX page, if you use RenderPartial, it should work.

like image 135
Andrew Stanton-Nurse Avatar answered Sep 29 '22 14:09

Andrew Stanton-Nurse


One thing I would watch out for is that if you use Master Pages then you may end up duplicating them for both view engines. I had a good ol' WebForms Master Page, used by all my regular .aspx content files, but creating a new view using Razor means I have to use a duplicate Razor layout page alongside that old Master Page.

I haven't looked into it too much, but at first try I get 'The file "~/Views/Shared/Site.Master" could not be rendered, because it does not exist or is not a valid page.' and certainly there's nothing in Scott Gu's blog entry introducing Razor to suggest you can combine them, but I could be all wrong here.

like image 43
Ralph Lavelle Avatar answered Sep 29 '22 15:09

Ralph Lavelle