【发布时间】: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