Skip to content

Commit

Permalink
Fix an error
Browse files Browse the repository at this point in the history
  • Loading branch information
chinadragon0515 committed Sep 26, 2016
1 parent 9724e44 commit ae7167a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void SetUseVerboseErrors(this HttpConfiguration configuration, boo
CultureInfo.InvariantCulture, Resources.ArguementsCannotbeNull, "configuration"));
}

configuration.Properties[useVerboseErrors] = useVerboseErrors;
configuration.Properties[UseVerboseErrorsFlagKey] = useVerboseErrors;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,57 @@ public string CreateSessionID(HttpContext context)

public string GetSessionID(HttpContext context)
{
var id = HttpContext.Current.Items["AspCookielessSession"] as string;
var id = context.Items["AspCookielessSession"] as string;
if (!string.IsNullOrEmpty(id))
{
return id;
}

// 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))/odata/path.
var originalUrl = HttpContext.Current.Request.Headers["X-Original-URL"];
var originalUrl = context.Request.Headers["X-Original-URL"];

if (!string.IsNullOrEmpty(originalUrl))
{
var match = Regex.Match(HttpContext.Current.Request.Headers["X-Original-URL"], @"/\(S\((\w+)\)\)");
var match = Regex.Match(originalUrl, @"S\((\w+)\)");
if (match.Success)
{
id = match.Groups[1].Value;
return id;
}
}

// Starting 2016/09/18, Azure request header does not contains X-Original-URL
// Note session will always null, URL parsing does not work neither
originalUrl = context.Request.Headers["AspFilterSessionId"];
if (!string.IsNullOrEmpty(originalUrl))
{
var match = Regex.Match(originalUrl, @"S\((\w+)\)");
if (match.Success)
{
id = match.Groups[1].Value;
return id;
}
}

// Try some cookieless logic
originalUrl = context.Request.Params["HTTP_ASPFILTERSESSIONID"];
if (!string.IsNullOrEmpty(originalUrl))
{
var match = Regex.Match(originalUrl, @"S\((\w+)\)");
if (match.Success)
{
id = match.Groups[1].Value;
return id;
}
}

var cookie = context.Request.Cookies["ASP.NET_SessionId"];
if (cookie != null)
{
return cookie.Value;
}

return id;
}

Expand Down

0 comments on commit ae7167a

Please sign in to comment.