zoukankan      html  css  js  c++  java
  • MVC项目后台管理,各页面判断登陆问题。

    public class BaseController : Controller
        {
            protected string hostUrl = "";
            /// <summary>
            /// Action执行前判断
            /// </summary>
            /// <param name="filterContext"></param>
            protected override void OnActionExecuting(ActionExecutingContext filterContext)
            {
                // url
                this.hostUrl = "http://" + this.Request.Url.Host;
                this.hostUrl += this.Request.Url.Port.ToString() == "80" ? "" : ":" + this.Request.Url.Port;
                this.hostUrl += this.Request.ApplicationPath;
     
                if (!this.checkLogin())// 判断是否登录
                {
                    filterContext.Result = RedirectToRoute("Default",new{ Controller = "Login", Action = "Index" });
                }
     
                base.OnActionExecuting(filterContext);
     
            }
     
     
            /// <summary>
            /// 判断是否登录
            /// </summary>
            protected bool checkLogin()
            {
                if (this.Session["userinfo"] == null)
                {
                    return false;
                }
                return true;
            }
     
        }
  • 相关阅读:
    MMA7660
    使用外设需要做的事情
    BH1750
    English
    2016年学习计划
    博客园
    TIM
    USART
    swift与oc的混合编程
    SVN工具如何创建分支和合并分支的
  • 原文地址:https://www.cnblogs.com/tinya/p/4500259.html
Copyright © 2011-2022 走看看