find a location for property in a new city

Tuesday, 8 June 2010

Use WebForms MasterPage in MVC project

Want to avoid having to duplicate your MasterPage design that you made in your ASP.NET WebForms project in you new MVC project? There is a simple way to share your master page across the ASP.NET web forms and MVC projects. Here's how:

Make a new "MVC 2 View Master Page" in your /Views/Shared folder and add the content:
<%@ Master Language="C#" MasterPageFile="~/MasterPages/Root.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="RootTitle" runat="server">
    <asp:ContentPlaceHolder ID="RootTitle" runat="server" />
<asp:Content ID="Content2" ContentPlaceHolderID="RootContent" runat="server">
    <asp:ContentPlaceHolder ID="RootContent" runat="server"/>

Replace the URL with the destination of your web forms MasterPage and the ContentPlaceHolderIDs with the respective ones you used in your original web forms master page.

You can then go on to use your new MVC master page as you would before but it will inherit all the content from your web forms master page.


Any form post controls on your web forms master page will not work on your MVC pages. I have found a way though which I explained in my post about making form posts work in a webform master page nested MVC page if that sort of thing interests you.

Follow britishdev on Twitter


  1. hhjjkkjjkkkkkkkkkkkkkk-+

  2. i want use webforms like masterpage

  3. what a well articulated comment

  4. exellent solution.. it really helped me.. thanks

  5. Informative post. I am happy to visit your blog. Thanks for sharing this post.
    electrical maintenance in chennai

  6. Good article. This is very useful, Thanks for sharing this post.
    school websites design

  7. Thank you for this great explanation. It was really helpful.

    3d rendering services

  8. Nice post! I like your post a lot and rendering images too. Keep posting such a nice blogs.
    3d rendering

  9. Bài viết bạn rất hay:

    Chúng tôi là đơn vị cung cấp các sản phẩm chất lượng như:

    Giảo cổ lam

    giảo cổ lam giải độc gan

    giảo cổ lam giảm béo

  10. Bài viết bạn rất hay:

    Chúng tôi là đơn vị cung cấp các sản phẩm chất lượng như:

    lều xông hơi

    lều xông hơi sau sinh

    lều xông hơi giá bao nhiêu

  11. Nice post

  12. I was studying some of your articles on this website and I think this website is real informative ! Keep on posting