码迷,mamicode.com
首页 > Web开发 > 详细

MVC 载入不同的MasterPage页面

时间:2015-06-04 15:11:42      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

public class GroupMasterPage : ActionFilterAttribute
    {
        private string _masterName;
        public GroupMasterPage(string masterName)
        {
            _masterName=masterName;
        }


        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            var result = filterContext.Result as ViewResult;
            if (result != null)
            {
                result.MasterName= _masterName;
            }
        }
    }

 

    [GroupMasterPage("SuccessPage")]
        public ActionResult Index(string orderid,int hotelid,int roomid)
        {
            bool IsSendEbooking =_Biz.GetSendEbooking(hotelid, roomid);
            O_Success Model = new O_Success();
            Model.IsSendEbooking = IsSendEbooking;
            Model.Orderid = orderid;
            

            if (IsSendEbooking)
            {
                Model.ProcessIFrameURL = ConfigHelper.GetConfigValue("OldSystemUrl") + "/cii/order/fax/faxtohotelpreprocess.asp?orderid=" + orderid;

                return View("~/Views/SuccessOrder/OrderProcess/index.cshtml",Model);
            }
            else
            {
                Model.ProcessOrderUrl = ConfigHelper.GetConfigValue("GroupSuccessUrl") + orderid;

                Model.QuickUrl = string.Format("http://" + UIHelper.GetAuthority().Replace("booking.hotel.", "service.") + "/cii/share/tNetV.asp?module=");

                return View("~/Views/SuccessOrder/OrderView/index.cshtml",Model);
            }
        }


_ViewStart.cshtml 页面


@
using Ctrip.HotelReservation.GroupHotel.Extensions; @{ if ((((RazorView)(this.ViewContext.View))).LayoutPath == "") { if (!Url.GetErrorView()) { Layout = "~/Views/Shared/_Layout.cshtml"; } } else { if (!Url.GetErrorView()) { //GroupMasterPage("SuccessPage") 载入路径为~/Views/Shared/SuccessPage.cshtml 模板页 Layout = (((RazorView)(this.ViewContext.View))).LayoutPath; } } }

MVC 载入不同的MasterPage页面

标签:

原文地址:http://www.cnblogs.com/kfsmqoo/p/4551554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!