From ed3bece16e239796c4c9086777ddb561d231dafa Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 1 Jul 2010 16:57:07 -0700 Subject: [PATCH] Slightly tweak the redirect code... --HG-- branch : dev --- src/Orchard.Web/Orchard.Web.csproj | 1 + src/Orchard.Web/Refresh.html | 15 +++++++++++++++ src/Orchard/Environment/DefaultOrchardHost.cs | 18 +++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/Orchard.Web/Refresh.html diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index a11c55af0..0fa586cba 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -99,6 +99,7 @@ + Designer diff --git a/src/Orchard.Web/Refresh.html b/src/Orchard.Web/Refresh.html new file mode 100644 index 000000000..d113ec296 --- /dev/null +++ b/src/Orchard.Web/Refresh.html @@ -0,0 +1,15 @@ + + + + Configuration Changing... + + +

+ Orchard is temporarily unavailable as a change in configuration requires a restart. + A simple page refresh usually solves this issue.

+ + + + diff --git a/src/Orchard/Environment/DefaultOrchardHost.cs b/src/Orchard/Environment/DefaultOrchardHost.cs index d32332c75..2f3ba5520 100644 --- a/src/Orchard/Environment/DefaultOrchardHost.cs +++ b/src/Orchard/Environment/DefaultOrchardHost.cs @@ -152,13 +152,21 @@ namespace Orchard.Environment { protected virtual void BeginRequest() { MonitorExtensions(); BuildCurrent(); + + // If setting up extensions/modules requires an AppDomain restart, it's very unlikely the + // current request can be processed correctly. So, we redirect to the same URL, so that the + // new request will come to the newly started AppDomain. if (_setupExtensionsContext.RestartAppDomain) { - if (HttpContext.Current != null) + if (HttpContext.Current != null) { // Don't redirect posts... - if (HttpContext.Current.Request.RequestType == "GET") - HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ToUrlString(), true/*endResponse*/); - else - throw new HttpException(T("Orchard is temporarily unavailable as a change in configuration requires a restart. A simple page refresh usually solve this issue.").Text); + if (HttpContext.Current.Request.RequestType == "GET") { + HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ToUrlString(), true /*endResponse*/); + } + else { + HttpContext.Current.Response.WriteFile("~/Refresh.html"); + HttpContext.Current.Response.End(); + } + } } }