• 一般处理程序用户登录验证


    <script src="../js/jquery-1.8.0.min.js"></script>
        <script type="text/javascript">
    
            //function success(s) {
            //    debugger;
            //    alert(1);
            //    if (s.global) {
            //        trigger("ajaxSuccess", [xhr, s]);
            //    }
            //    // If a local callback was specified, fire it and pass it the data
            //    if (s.success && xhr.responseText != "unlogin") {
            //        s.success.call(callbackContext, data, status, xhr);
            //    }
            //}
            $(function () {
                debugger;
                alert(2);
                $.ajax({
                    type: 'post',
                    url: 'a.ashx',
                    success:
                function (msg) {
                    alert(msg);
                  
                    
                    }
    
                })
    
    
            })
            $(document).ajaxSuccess(function (event, xhr, settings) {
                if (xhr.responseText == "unlogin") {
                    window.top.location.href = "http://www.baidu.com";
                    
                }
            })
            </script>
    

      

    一般处理程序类后要加System.Web.SessionState.IRequiresSessionState接口,否则找不到HttpContext.Current.Session["aa"],

     public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
         
            if (HttpContext.Current.Request.UrlReferrer.ToString().ToLower().IndexOf("login.html") < 0)
            {
             
                if (HttpContext.Current.Session["aa"] == null )
                {
                    HttpContext.Current.Response.Write("unlogin");
                    HttpContext.Current.Response.End();
                    //context.Response.Write("unlogin");
                }
            }
            //context.Response.Write("Hello World");
        }

  • 相关阅读:
    Linux中Shell的算数运算符和位运算符用法笔记
    Linux中Shell的算数运算符和位运算符用法笔记
    Linux中Shell的命令替换用法笔记
    Linux中Shell的命令替换用法笔记
    Linux中shell变量作用域笔记
    Linux中shell变量作用域笔记
    模块进阶、标准库、扩展库
    模块的导入
    私有化
    python作用域与LEGB规则
  • 原文地址:https://www.cnblogs.com/zhubenxi/p/5160379.html
Copyright © 2020-2023  润新知