首页 > 代码库 > Infinite loop when using cookieless session ID on Azure
Infinite loop when using cookieless session ID on Azure
If you use cookieless session ID and deploy them on Azure, you might get infinite loop when you query your web site, and browser would down. In this scenario, you need to overwrite ASP.NET default ISessionIDManager.
In method GetSessionID, your could should be below
public string GetSessionID(HttpContext context){ var id = HttpContext.Current.Items["AspCookielessSession"] as string; // Azure web site does not support header "AspFilterSessionId", so we cannot get context.Items["AspCookielessSession"] // for azure web site use, Headers["X-Original-URL"] format: /(S(xxx))/default.aspx var originalUrl = HttpContext.Current.Request.Headers["X-Original-URL"]; if (!string.IsNullOrEmpty(originalUrl)) { var match = Regex.Match(HttpContext.Current.Request.Headers["X-Original-URL"], @"/\(S\((\w+)\)\)"); if (match.Success) { id = match.Groups[1].Value; } } return id;}
Don‘t forget to change your web.config file.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。