fix #1156 add defensive coding for scenario where host name does not match any alias
This commit is contained in:
parent
6d3e17a5f5
commit
86ce8994d9
|
@ -1,4 +1,4 @@
|
||||||
@page "/"
|
@page "/"
|
||||||
@namespace Oqtane.Pages
|
@namespace Oqtane.Pages
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
@using Microsoft.Extensions.Configuration
|
@using Microsoft.Extensions.Configuration
|
||||||
|
@ -35,6 +35,11 @@
|
||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (Model.Message != "")
|
||||||
|
{
|
||||||
|
@Model.Message
|
||||||
|
}
|
||||||
|
|
||||||
<script src="js/interop.js"></script>
|
<script src="js/interop.js"></script>
|
||||||
|
|
||||||
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
|
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Oqtane.Pages
|
||||||
|
|
||||||
public string HeadResources = "";
|
public string HeadResources = "";
|
||||||
public string BodyResources = "";
|
public string BodyResources = "";
|
||||||
|
public string Message = "";
|
||||||
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,10 @@ namespace Oqtane.Pages
|
||||||
if (HttpContext.Request.Cookies[CookieRequestCultureProvider.DefaultCookieName] == null && !string.IsNullOrEmpty(_configuration.GetConnectionString("DefaultConnection")))
|
if (HttpContext.Request.Cookies[CookieRequestCultureProvider.DefaultCookieName] == null && !string.IsNullOrEmpty(_configuration.GetConnectionString("DefaultConnection")))
|
||||||
{
|
{
|
||||||
var uri = new Uri(Request.GetDisplayUrl());
|
var uri = new Uri(Request.GetDisplayUrl());
|
||||||
var alias = _aliases.GetAlias(uri.Authority + "/" + uri.LocalPath.Substring(1));
|
var hostname = uri.Authority + "/" + uri.LocalPath.Substring(1);
|
||||||
|
var alias = _aliases.GetAlias(hostname);
|
||||||
|
if (alias != null)
|
||||||
|
{
|
||||||
_state.Alias = alias;
|
_state.Alias = alias;
|
||||||
|
|
||||||
// set default language for site if the culture is not supported
|
// set default language for site if the culture is not supported
|
||||||
|
@ -70,6 +74,11 @@ namespace Oqtane.Pages
|
||||||
SetLocalizationCookie(_localizationManager.GetDefaultCulture());
|
SetLocalizationCookie(_localizationManager.GetDefaultCulture());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Message = $"No Matching Alias For Host Name {hostname}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessHostResources(Assembly assembly)
|
private void ProcessHostResources(Assembly assembly)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user