Hello Volosoft Representatives, After upgrading to Abp 5.1 we were able to get our project to run in Visual Studio. However, when we published to IIS we got the following error:
Which was from the following code block in Global.asax.cs:
private void RestoreUserLanguage()
{
var settingManager = AbpBootstrapper.IocManager.Resolve<ISettingManager>();
var defaultLanguage = settingManager.GetSettingValue(LocalizationSettingNames.DefaultLanguage);
if (defaultLanguage.IsNullOrEmpty())
{
return;
}
try
{
CultureInfo.GetCultureInfo(defaultLanguage);
Response.Cookies.Add(new HttpCookie("Abp.Localization.CultureName", defaultLanguage) { Expires = Clock.Now.AddYears(2) });
}
catch (CultureNotFoundException exception)
{
LogHelper.Logger.Warn(exception.Message, exception);
}
}
We were able to reproduce this without making any customizations other than changing the connection string by cloning from aspnet-zero on the latest dev branch, we ran update-database -verbose and then published to IIS.
Is there anyway to resolve this?
2 Answer(s)
-
1
Possible duplicate of aspnetboilerplate/aspnetboilerplate#5138, which has a fix that will be released in ABP v5.2.
Meanwhile, you can resolve this by subclassing
WebClientInfoProvider
with the fix from aspnetboilerplate/aspnetboilerplate#5139 and replace serviceIClientInfoProvider
. -
0
Dear @Aaron,
Thanks. We were able to apply the workaround with the following code:
WebClientInfoProviderHack.cs
namespace MyCompanyName.AbpZeroTemplate.Web.Hacks { using Abp.Auditing; using System; using System.Net; using System.Net.Sockets; using System.Web; public class WebClientInfoProviderHack : WebClientInfoProvider { protected override string GetClientIpAddress() { var httpContext = HttpContext.Current; if (httpContext?.Request.ServerVariables == null) return null; var clientIp = httpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? httpContext.Request.ServerVariables["REMOTE_ADDR"]; // Remove port if present clientIp = clientIp.Contains(":") ? clientIp.Remove(clientIp.IndexOf(':')) : clientIp; try { foreach (var hostAddress in Dns.GetHostAddresses(clientIp)) if (hostAddress.AddressFamily == AddressFamily.InterNetwork) return hostAddress.ToString(); foreach (var hostAddress in Dns.GetHostAddresses(Dns.GetHostName())) if (hostAddress.AddressFamily == AddressFamily.InterNetwork) return hostAddress.ToString(); } catch (Exception ex) { Logger.Debug(ex.ToString()); } return clientIp; } } }
AbpZeroTemplateWebModule.cs
public override void PreInitialize() { // elided code here Configuration.ReplaceService<IClientInfoProvider, WebClientInfoProviderHack>(); }