【问题标题】:Exception during execution from Internet Information Service从 Internet 信息服务执行期间出现异常
【发布时间】:2014-08-27 12:07:20
【问题描述】:

我正在一个网站上工作,从 Visual Studio 2008 打开时它运行良好,但从 IIS(Internet 信息服务)打开时,它给出以下错误:

长度不能小于零。

参数名称:长度

描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。

异常详细信息:System.ArgumentOutOfRangeException:长度不能 小于零。参数名称:长度

来源错误:

Line 174:  StringBuilder sb = new StringBuilder(id, 512);
Line 175:  ////append the first segment of the user's ip address to the string 
Line 176:  sb.Append(ipAddress 
                         .Substring(0, 
                                    ipAddress.IndexOf(".", 
                                                      ipAddress.IndexOf(".") + 1)));
Line 177:  ////append the users User Agent to the string 
Line 178:  sb.Append(userAgent);

源文件:

d:\HiFi\HRM_Module\HRM\Global.asax 行:176

堆栈跟踪:

[ArgumentOutOfRangeException: 长度不能小于 零。参数名称:长度] System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 长度,布尔值 fAlwaysCopy) +10090344 ASP.global_asax.CreateMAC(字符串 id,字符串 ipAddress,字符串 userAgent,字符串验证键)在 d:\HiFi\HRM_Module\HRM\Global.asax:176 ASP.global_asax.Application_BeginRequest(对象发送者,EventArgs e) 在 d:\HiFi\HRM_Module\HRM\Global.asax:77 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

版本信息:

  • Microsoft .NET 框架版本:2.0.50727.8009;
  • ASP.NET 版本:2.0.50727.8008

【问题讨论】:

  • 好像ipAddress.IndexOf 返回-1。
  • @L.B 那么有什么办法可以消除错误。

标签: c# asp.net .net asp.net-mvc iis


【解决方案1】:

如果您使用本地环境来托管您的网站,则 Request 对象会以 IpAddress 的形式返回“::1”,即不包含“.” 这可能是您的问题的原因。

【讨论】:

    【解决方案2】:

    如果您输入 //您的 ipadress/网站名称

    ,它将起作用

    例如从 IIS 打开后的 10.11.129.233/HRM。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      相关资源
      最近更新 更多