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 –