• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
周巍
学习生活,学习技术,也学习英语
博客园    首页    新随笔    联系   管理    订阅  订阅

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.

 

posted @ 2014-06-28 10:37  周巍  阅读(367)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3