Use IHttpExceptionStatusCodeFinder to find the http status code

pull/301/head
Halil İbrahim Kalkan 8 years ago
parent df26759e74
commit 510eee82e2

@ -15,7 +15,7 @@
} }
<h1> <h1>
[@Model.HttpStatusCode] @errorMessage [@Model.HttpStatusCode] @errorMessage
</h1> </h1>
<div> <div>

@ -15,10 +15,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Pages.Error
public int HttpStatusCode { get; set; } public int HttpStatusCode { get; set; }
private readonly IExceptionToErrorInfoConverter _errorInfoConverter; private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
public IndexModel(IExceptionToErrorInfoConverter errorInfoConverter) public IndexModel(IExceptionToErrorInfoConverter errorInfoConverter, IHttpExceptionStatusCodeFinder statusCodeFinder)
{ {
_errorInfoConverter = errorInfoConverter; _errorInfoConverter = errorInfoConverter;
_statusCodeFinder = statusCodeFinder;
} }
public void OnGet() public void OnGet()
@ -33,8 +35,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Pages.Error
if (HttpStatusCode == 0) if (HttpStatusCode == 0)
{ {
HttpStatusCode = HttpContext.Response.StatusCode; HttpStatusCode = (int)_statusCodeFinder.GetStatusCode(HttpContext, exception);
} }
HttpContext.Response.StatusCode = HttpStatusCode;
} }
} }
} }

@ -23,7 +23,7 @@ namespace Volo.Abp.Settings
public static T Get<T>([NotNull] this ISettingManager settingManager, [NotNull] string name, T defaultValue = default) public static T Get<T>([NotNull] this ISettingManager settingManager, [NotNull] string name, T defaultValue = default)
where T : struct where T : struct
{ {
return AsyncHelper.RunSync(() => settingManager.GetAsync<T>(name, defaultValue)); return AsyncHelper.RunSync(() => settingManager.GetAsync(name, defaultValue));
} }
public static bool IsTrue([NotNull] this ISettingManager settingManager, [NotNull] string name) public static bool IsTrue([NotNull] this ISettingManager settingManager, [NotNull] string name)

Loading…
Cancel
Save