Skip to content

Commit

Permalink
nopSolutions#4765 Fixed "503" error during the application restart
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMaz committed May 19, 2020
1 parent 049a623 commit 0565bf0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/Libraries/Nop.Core/IWebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public partial interface IWebHelper
/// <summary>
/// Restart application domain
/// </summary>
/// <param name="makeRedirect">A value indicating whether we should made redirection after restart</param>
void RestartAppDomain(bool makeRedirect = false);
void RestartAppDomain();

/// <summary>
/// Gets a value that indicates whether the client is being redirected to a new location
Expand Down
34 changes: 2 additions & 32 deletions src/Libraries/Nop.Core/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,6 @@ protected virtual bool IsIpAddressSet(IPAddress address)
return address != null && address.ToString() != IPAddress.IPv6Loopback.ToString();
}

/// <summary>
/// Try to write web.config file
/// </summary>
/// <returns></returns>
protected virtual bool TryWriteWebConfig()
{
try
{
_fileProvider.SetLastWriteTimeUtc(_fileProvider.MapPath(NopInfrastructureDefaults.WebConfigPath), DateTime.UtcNow);
return true;
}
catch
{
return false;
}
}

#endregion

#region Methods
Expand Down Expand Up @@ -411,22 +394,9 @@ public virtual T QueryString<T>(string name)
/// <summary>
/// Restart application domain
/// </summary>
/// <param name="makeRedirect">A value indicating whether we should made redirection after restart</param>
public virtual void RestartAppDomain(bool makeRedirect = false)
public virtual void RestartAppDomain()
{
//the site will be restarted during the next request automatically
//"touch" web.config to force restart
var success = TryWriteWebConfig();
if (!success)
{
throw new NopException("nopCommerce needs to be restarted due to a configuration change, but was unable to do so." + Environment.NewLine +
"To prevent this issue in the future, a change to the web server configuration is required:" + Environment.NewLine +
"- run the application in a full trust environment, or" + Environment.NewLine +
"- give the application write access to the 'web.config' file.");
}

if (Environment.OSVersion.Platform == PlatformID.Unix)
_hostApplicationLifetime.StopApplication();
_hostApplicationLifetime.StopApplication();
}

/// <summary>
Expand Down

0 comments on commit 0565bf0

Please sign in to comment.