Geeks With Blogs

News Opinions and articles on this blog are mine alone and do not represent my employer. All articles and blog entries are posted using a personal computer system outside of my employer network.
Sam Abraham Software Engineer/Architect: Putting Customers First
The biggest question as a new version of a product or framework comes out is whether an upgrade path from the prior version exists and if the new features introduced are worth the headache and time investment made to upgrade.
 
For ASP.Net MVC 3, the answer is yes to both questions. Personally, I would wait until ASP.Net MVC 3 is officially released, but for those wanting to upgrade right away, details for the upgrade can be found here and are pretty straight forward.
 
Today, I decided to tackle a potential approach companies might consider to leverage the new Razor View Engine while keeping already-developed ASPX View Engine pages.  For my example below, I started with an MVC 3 project that uses the ASPX View Engine, then added support for Razor to allow both to run side-by-side in the same project. The following is my initial ASPX View Engine project structure.
 
 Figure 1 - ASPX View Engine Project Structure
 
 
Although this project is initially created using the ASPX view engine, note that we still have the option to create a Razor view enabled as shown below. However, note the selected master page (_Layout.cshtml) does not exist, so when we click OK, Visual Studio reminds us of the same.
 
Figure 2 - Creating a Razor view page
 
 
 Figure 3 - _Layout.cshtml is not found.
 
To fix this error, we had to create two projects _Layout.cshtml and a _ViewStart.cshtml to store the global layout definition. Once these pages are added the add razor view engine now becomes functional and with testing we can see that both now work. A good hint I found on a blog post to get this going quickly is to copy the missing .cshtml files from a different Razor project to avoid having to manually code the files content.
 
Figure 4- Project structure  supporting both Razor and APX View Engines 
 
--Sam Abraham

 

Posted on Wednesday, October 13, 2010 9:39 AM Fladotnet.com , Tech Talk , VS2010 , MVC2 , WebMatrix , ASP .Net MVC 3 , ASP.Net MVC 3 Beta , Razor Pages , ASP.Net Web Pages , MVC 3 | Back to top


Comments on this post: Combining ASP.Net MVC 3 Razor and ASPX View Engines in One Project

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Sam Abraham | Powered by: GeeksWithBlogs.net