码迷,mamicode.com
首页 > 其他好文 > 详细

Infinite loop when using cookieless session ID on Azure

时间:2014-07-07 21:29:24      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   for   io   

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.

 

Infinite loop when using cookieless session ID on Azure,布布扣,bubuko.com

Infinite loop when using cookieless session ID on Azure

标签:style   blog   http   color   for   io   

原文地址:http://www.cnblogs.com/MyNameEPC/p/3813076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!