zoukankan      html  css  js  c++  java
  • 一般处理程序用户登录验证

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

  • 相关阅读:
    编写一个C语言程序,产生一个存放26个英文字母组成的线性链表(a,b,c,…,z),并输出该线性表。
    JavaScript之数组函数
    JavaScript之数据类型转化
    xml约束
    PHP初认识
    JavaScript与css3
    JavaScript与css
    HTML5与JavaScript
    JSON
    xml初认识
  • 原文地址:https://www.cnblogs.com/zhubenxi/p/5160379.html
Copyright © 2011-2022 走看看