1
我正在使用ashx文件来终止用户会话并重定向到主页面。重定向不起作用以及例程过期cookies。 我试过HttpContext.Current.Response.Redirect(“index.aspx”,false),但也没有工作。有什么更好的办法谢谢。过期的Cookie和重定向
我的代码:
public void ProcessRequest (HttpContext context)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies["user"];
if (cookie != null)
HttpContext.Current.Request.Cookies["user"].Expires = DateTime.Now.AddYears(-30);
cookie = HttpContext.Current.Request.Cookies["admin"];
if (cookie != null)
HttpContext.Current.Request.Cookies["admin"].Expires = DateTime.Now.AddYears(-30);
HttpContext.Current.Response.Redirect("index.aspx", false);
}
你是怎么调用这个Generic Handler(.ashx)的?你通过ajax打电话吗? –
是的,通过一个包含ajax命令来调用logout.ashx的javascript例程。 注销功能() { $就({ URL: “logout.ashx” 的contentType: “应用程序/ JSON;字符集= UTF-8” 数据类型: “HTML” }) } – Luana
我看到一个类似的帖子:http://stackoverflow.com/questions/17866856/trying-to-redirect-from-an-ashx-page-to-an-aspx-page –