我需要在我的应用程序(ASP.NET MVC)上支持不同的母版页。
推荐的方法是:
最佳答案
使用自定义基本 Controller 并从其继承:
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
我在global.asax Session_Start中设置了Session变量:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
//programming to figure out your session
Session("MasterPage")="MyMasterPage"
End Sub
关于asp.net-mvc - 在ASP.NET MVC中动态更改主模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/272313/