导航到Web应用程序上的一页时,出现“未知主机未知”错误,但导航到另一页时没有错误

时间:2020-04-30 02:43:53

标签: c# dns

我有一个Web应用程序,可以出于不同目的导航到不同页面。部署后,用户将收到以下错误。

Server Error in '/' Application.

No such host is known

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.Sockets.SocketException: No such host is known

Source Error: 

An unhandled exception was generated during the execution of the current web request.     Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[SocketException (0x2af9): No such host is known]
  System.Net.Dns.InternalGetHostByAddress(IPAddress address, Boolean includeIPv6) +3192148
  System.Net.Dns.GetHostEntry(String hostNameOrAddress) +8777246
  _Default.TerminalName(HttpRequest, Request) +46
  _Default.TerminalDefaultLocation(HttpRequest, PageRequest) +125
  _Default.Page_Load(Object sender, EventArgs e) +320
  System.EvantHandler.Invoke(Object sender, EventArgs e) +0
  System.Web.UI.Control.OnLoad(EventArgs e) +106
  System.Web.UI.Control.LoadRecursive() +68
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178

 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3535.0

但是,当用户导航到同一Web应用程序上的另一个页面时,没有任何错误,并且页面可以正常加载。

Web应用程序上的所有页面都使用相同的功能

public static string TerminalName(System.Web.HttpRequest Request)
{
    bool trim = false;

    string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });
    string tName = computer_name[0].ToString();

    //string tName = Request.ServerVariables["REMOTE_ADDR"];
    int period = tName.IndexOf(".");

    if (period > 0 && trim)
        tName = tName.Substring(0, period);
    return tName;
}

我不确定为什么在一页而不是另一页上出错。

此外,当我通过VS在本地主机上运行Web应用程序时,它运行正常。

P.S .:我在这个论坛和其他地方进行了广泛的搜索,但是找不到解决我问题的方法。

更新:在另一位同事的系统上进行了测试,该应用程序运行正常。现在,我更加困惑为什么它不能在某些系统上运行而在其他系统上运行。

0 个答案:

没有答案