我需要在我的应用程序(ASP.NET MVC)上支持不同的母版页。
推荐的方法是什么:
- 将母版页名称传递给视图。
- 存储母版页(在会话中或其他内容中),以便在用户访问期间保留它。
使用自定义基本控制器并继承它:
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 中设置会话变量:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
//programming to figure out your session
Session("MasterPage")="MyMasterPage"
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)