I want to start migrating a WebForms App to MVC. The process will be gradual, so both systems must co-exist.
The question is: Should I have two MasterPages, one for the WebForms pages and other for the MVC views? Is there a way to have only one?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In ASP.NET MVC the master page should derive from
System.Web.Mvc.ViewMasterPagewhile in classic WebForms fromSystem.Web.UI.MasterPage. If in MVC you use the latter you won’t have access to any helpers. Although you could useViewMasterPagein classic webforms because it derives fromMasterPage(once again you won’t have access to helpers in the web forms application but who cares).So to answer your question, yes, you could have a common master page assuming it derives from
ViewMasterPage.This being said you probably won’t be able to make this work as in an MVC master page you would use HTML helpers to render partial views like
Html.RenderPartialwhich doesn’t make much sense in a classic WebForms application and vice versa in a classic WebForms application you would probably be using some server side controls like<asp:xxx runat="server" />or have a singleformtag (again withrunat="server") polluted with ViewState, etc… which hardly makes any sense in MVC. So my recommendation would be not to do like this.