From ea911858167352b8fe6e8e5bde07920e66747c25 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 24 Jul 2015 10:34:37 +0100 Subject: [PATCH] Falling back to a default base URL in case none is configured. This fixes an issue where you run Setup from a command line and the recipe does not set BaseUrl on site settings. The issue is that if the HttpContext does not have a URL, certain properties on the Request object will throw when constructing a URI with a null value. --- src/Orchard/Mvc/HttpContextAccessor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Orchard/Mvc/HttpContextAccessor.cs b/src/Orchard/Mvc/HttpContextAccessor.cs index 34f50c7a9..8fe8e4f0a 100644 --- a/src/Orchard/Mvc/HttpContextAccessor.cs +++ b/src/Orchard/Mvc/HttpContextAccessor.cs @@ -21,7 +21,8 @@ namespace Orchard.Mvc { public HttpContextBase CreateContext(ILifetimeScope lifetimeScope) { return new MvcModule.HttpContextPlaceholder(_threadStaticContexts, _contextKey, () => { - return lifetimeScope.Resolve().GetSiteSettings().BaseUrl; + var baseUrl = lifetimeScope.Resolve().GetSiteSettings().BaseUrl; + return !String.IsNullOrEmpty(baseUrl) ? baseUrl : "http://localhost"; // Return a valid URL always. }); }