From fc38e0eb5dd785a0f9fa89bf3b9214d88c018918 Mon Sep 17 00:00:00 2001 From: ViRuSTriNiTy Date: Thu, 17 Aug 2017 21:12:02 +0200 Subject: [PATCH] [Fixes #7811] Fixes exception occurred when BaseUrl setting is not set (#7813) Fixes #7811 --- src/Orchard/Mvc/MvcModule.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Orchard/Mvc/MvcModule.cs b/src/Orchard/Mvc/MvcModule.cs index 772eec403..93d69fa8d 100644 --- a/src/Orchard/Mvc/MvcModule.cs +++ b/src/Orchard/Mvc/MvcModule.cs @@ -40,9 +40,12 @@ namespace Orchard.Mvc { // which requires activating the Site content item, which in turn requires a UrlHelper, which in turn requires a RequestContext, // thus preventing a StackOverflowException. - var baseUrl = new Func(() => - siteService.GetSiteSettings().BaseUrl - ?? "http://localhost" /* When Setup is running from the command line, no BaseUrl exists yet. */); + var baseUrl = new Func(() => { + var s = siteService.GetSiteSettings().BaseUrl; + + // When Setup is running from the command line, no BaseUrl exists yet. + return string.IsNullOrEmpty(s) ? "http://localhost" : s; + }); var httpContextBase = new HttpContextPlaceholder(baseUrl);