一般处理程序用户登录验证
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一般处理程序用户登录验证相关的知识,希望对你有一定的参考价值。
<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");
}
以上是关于一般处理程序用户登录验证的主要内容,如果未能解决你的问题,请参考以下文章