CHAMPION KAY TUTORIAL

Using Razor views with Webforms master page

While the new Razor view enginge for ASP.NET MVC3 looks fantastic, I haven't been able to dive into it quite yet. I soon discovered that you cannot mix and match Razor views with your old Webforms master page. You could have two master pages, but ideally you don't want to write the same code and markup twice.

Scott Hanselman presents a solution. "Can I mix Razor Views and WebForms Views in a single ASP.NET MVC application?", he asks. The answer is, "No, Yes, and Maybe, But It's Not Supported."

Anyways, the solutions is found on his blog.

In order to get the page title to work properly, I've done the following:

In the Controller:




1
ViewBag._Title = "Admin";


In the RazorView.aspx:
1
2
3
4
<%
    if (ViewBag._Title != null)
        Page.Title = ViewBag._Title;
%>

0 comments:

Post a Comment