filterContext.HttpContext.Response.Write("<script>top.location.href = '/Login/Index';</script>");
              

在使用超时设置时在本机调试时可以返回登录页面,在本机部署也可以,但是在服务器部署后没有跳转到登录页面,报错,以前的代码如下:

public class HandlerLoginAttribute : AuthorizeAttribute
    {
        public bool Ignore = true;
        public HandlerLoginAttribute(bool ignore = true)
        {
            Ignore = ignore;
        }
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (Ignore == false)
            {
                return;
            }
            if (OperatorProvider.Provider.GetCurrent() == null)
            {
                WebHelper.WriteCookie("schemedesign_login_error", "overdue");
               filterContext.HttpContext.Response.Write("<script>top.location.href = '/Login/Index';</script>");
              
                return;
            }
        }
    }

困惑了很久,后面看见网上别人的代码有些不一样,替换了这段代码:

filterContext.HttpContext.Response.Write("<script>top.location.href = '/Login/Index';</script>");
              
替换为如下:

filterContext.HttpContext.Response.Redirect("/Login/Index");

测试后可行,问题解决了,但是不知道是什么原因,最开始那个没有成功。个人猜测是环境的原因,所以以后还是用后面这种,都可以执行跳转。

最新文章

  1. Mina、Netty、Twisted一起学(八):HTTP服务器
  2. [每日电路图] 9、介绍一种低价简单的4.2V锂电池充电及稳压(LDO)电路——RT9193,SD8017
  3. CSS3样式运用,悬浮立体方块
  4. mongodb windows下的安装
  5. bzoj3503
  6. SQL 2005远程连接是出错(provider: SQL 网络接口, error: 28 - 服务器不支持请求的协议
  7. ubuntu matplotlib 安装
  8. C#游戏框架uFrame
  9. AFNetworking 用法详解
  10. 手機Web頁面信息
  11. Linux创建普通用户
  12. Windows安装Git
  13. Wireshark:couldn&#39;t run dumpcap in child process(附带Linux下探索过程)
  14. SpringBoot 配置阿里巴巴Druid连接池
  15. Consul集群搭建
  16. 解决U盘拷贝时提示文件过大问题(不能拷贝超过4个g的文件)
  17. JavaScript判断变量是否为数组的方法(Array)
  18. DataWindow.Net组件示例(全部开源)
  19. 字符编解码的故事(ASCII,GBK,Unicode,Utf-8区别)
  20. jmGraph:一个基于html5的简单画图组件

热门文章

  1. bootstrap中模态框的大小设置;
  2. 【BZOJ3796】Mushroom追妹纸 二分+hash
  3. 九度OJ 1076:N的阶乘 (数字特性、大数运算)
  4. segnet 编译与测试
  5. git 从远端拉取指定分支和推送本地某个分支到远端
  6. CountDownLatch,CyclicBarrier,Semaphore的使用
  7. Node.js学习笔记(2):基本模块
  8. map select reduce
  9. SNMP服务安装 Centos6.8环境网络安装
  10. UVA - 10305 【全排列】