首页 > 其他 > 详细

跳转到指定页面的回调

时间:2015-09-11 10:19:36      阅读:252      评论:0      收藏:0      [点我收藏+]

可以通过处理请求开始的回调来指定跳转的到指定的页面

[RegisterTo(typeof(IApplicationBeginRequestCallback))]

 

示列代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using ZKWebFramework.Model.Callbacks;
using ZKWebFramework.Utils.Collections;

namespace YiMei.Main.Callbacks {
    /// <summary>
    /// 处理请求开始的回调
    /// </summary>
    [RegisterTo(typeof(IApplicationBeginRequestCallback))]
    public class ApplicationBeginRequestCallback :
        DefaultExecuteOrder, IApplicationBeginRequestCallback {
        /// <summary>
        /// 重定向登录,注册,首页
        /// </summary>
        public void OnBeginRequest() {
            var context = HttpContext.Current;
            var path = context?.Request.Path.ToLower();
            if (context.Request.HttpMethod.ToLower() == "get") {
                if (path == "/index")
                    context?.Response.Redirect("/yimei_home/index");
            }
        }
    }
}

 

跳转到指定页面的回调

原文:http://www.cnblogs.com/zhongku/p/4800017.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!