我首先在Controller中用Session["hostid"]存放了判别信息:
然后在View页面中添加如下代码:
<script runat="server">
protected void Page_PreInit(object sender, EventArgs e)
{
switch (Session["hostid"].ToString())
{
case "read": this.Page.MasterPageFile = "~/Views/Shared/MerchantUser.Master";
break;
case "boss": this.Page.MasterPageFile = "~/Views/Shared/BossMerchantUsr.Master";
break;
}
}
</script>
经过验证,是可以得到想要的结果的。
参考文章:
http://www.haogongju.net/art/883243