Reputation: 25001
I have the requirement to support different Master pages on my application (ASP.NET MVC). What is the recommended way to:
Upvotes: 5
Views: 5456
Reputation: 1031
Why not keep the Master Page on the user profile? Then just change it on the PreLoad event.
http://www.odetocode.com/articles/440.aspx
Upvotes: -2
Reputation: 28248
Use a custom base controller and inherit from it instead:
Public Class CustomBaseController
Inherits System.Web.Mvc.Controller
Protected Overrides Function View(ByVal viewName As String, ByVal masterName As String, ByVal model As Object) As System.Web.Mvc.ViewResult
Return MyBase.View(viewName, Session("MasterPage"), model)
End Function
End Class
I set my Session variable in the global.asax Session_Start:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
//programming to figure out your session
Session("MasterPage")="MyMasterPage"
End Sub
Upvotes: 9