zhongku

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

[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");
            }
        }
    }
}

 

分类:

技术点:

相关文章: