Base solution for your next web application
Open Closed

Error in Azure #4421


User avatar
0
thor created

Hi,

Have downloaded and installed MVC5 and Angular. Everything is working fine locally.

The system is deployed to Azure.

I get "An error has occurred! - Error detail not sent by server." when I log in to the angular app. The username in the top right corner is showing {{vm.getShownUserName()}}. All appears to be working fine using a mobile instead of a desktop browser.

The error message in app_data/logs is showing:

DEBUG 2018-01-01 03:59:44,447 [13 ] Abp.Auditing.WebClientInfoProvider - System.Net.Sockets.SocketException (0x80004005): No such host is known at System.Net.Dns.GetAddrInfo(String name) at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6) at System.Net.Dns.GetHostAddresses(String hostNameOrAddress) at Abp.Auditing.WebClientInfoProvider.GetClientIpAddress() in D:\Github\aspnetboilerplate\src\Abp.Web\Auditing\WebClientInfoProvider.cs:line 53

"Help me Obi Wan..." ;)


2 Answer(s)
  • User Avatar
    0
    thor created

    Looking in github line 53 in WebClientInfoProvider:

    foreach (var hostAddress in Dns.GetHostAddresses(clientIp))
    

    I suspect clientIp could be null because that is called using

    var clientIp = httpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ??  httpContext.Request.ServerVariables["REMOTE_ADDR"];
    

    and this method is mentioned here:

    [https://stackoverflow.com/questions/46515568/how-to-get-clients-ip-address-on-an-azure-web-app-developed-in-asp-net])

    See comment:

    I tried System.Web.HttpContext.Current.Request.ServerVariables["REMO‌​TE_ADDR"]; but it returns null so does ["HTTP_X_FORWARDED_FOR"] – EidolonMK Oct 1 '17 at 18:35

  • User Avatar
    0
    alper created
    Support Team

    can you replace the code to retrieve the clientIP

    foreach (var hostAddress in Dns.GetHostAddresses(clientIp))
    ...
    

    with this line

    var clientIp =  HttpContext.Features.Get<IHttpConnectionFeature>().RemoteIpAddress;