mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Better fix for #20385
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user