Better fix for #20385

This commit is contained in:
Sebastien Ros
2014-03-24 15:32:52 -07:00
parent 8bda4bc6cc
commit e298a86081
2 changed files with 21 additions and 10 deletions

View File

@@ -107,15 +107,21 @@ namespace Orchard.Environment {
public ShellSettings Match(HttpContextBase httpContext) {
// use Host header to prevent proxy alteration of the orignal request
var httpRequest = httpContext.Request;
if(httpRequest == null) {
try {
var httpRequest = httpContext.Request;
if (httpRequest == null) {
return null;
}
var host = httpRequest.Headers["Host"];
var appRelativeCurrentExecutionFilePath = httpRequest.AppRelativeCurrentExecutionFilePath;
return Match(host ?? string.Empty, appRelativeCurrentExecutionFilePath);
}
catch(HttpException) {
// can happen on cloud service for an unknown reason
return null;
}
var host = httpRequest.Headers["Host"];
var appRelativeCurrentExecutionFilePath = httpRequest.AppRelativeCurrentExecutionFilePath;
return Match(host ?? string.Empty, appRelativeCurrentExecutionFilePath);
}
public ShellSettings Match(string host, string appRelativePath) {

View File

@@ -67,9 +67,14 @@ namespace Orchard.Logging {
ThreadContext.Properties["Tenant"] = ShellSettings.Name;
}
var ctx = HttpContext.Current;
if (ctx != null && ctx.Request != null) {
ThreadContext.Properties["Url"] = ctx.Request.Url.ToString();
try {
var ctx = HttpContext.Current;
if (ctx != null) {
ThreadContext.Properties["Url"] = ctx.Request.Url.ToString();
}
}
catch(HttpException) {
// can happen on cloud service for an unknown reason
}
}