请教:有谁遇到过这样的错误 Length cannot be less than zero
页面上通过发送request给dll文件处理请求,出现下面的异常
Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
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:
[ArgumentOutOfRangeException: Length cannot be less than zero.Parameter name: length] System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10079752 Krystalware.HttpUploadManager.MultipartParser.ReadHeaders() in \operation_web\HttpUploadManager\MultipartParser.cs:130 KSystem.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
在dll中有用到readheader方法,这个方法用问题吗?因为它的substring 看上去好像和出错信息相似
protected NameValueCollection ReadHeaders()
{
NameValueCollection headers = new NameValueCollection();
string line = ReadHeaderLine(_s);
// TODO: Handle continuations - lines starting with whitespace
while (line.Length > 0)
{
int pos = line.IndexOf(':');
headers[line.Substring(0, pos)] = line.Substring(pos + 1);
line = ReadHeaderLine(_s);
}
return headers;
}