ASP.NET 5 RC1:System.IO.InvalidDataException:请求内容意外结束

Posted

技术标签:

【中文标题】ASP.NET 5 RC1:System.IO.InvalidDataException:请求内容意外结束【英文标题】:ASP.NET 5 RC1: System.IO.InvalidDataException: Unexpected end of request content 【发布时间】:2015-12-22 14:29:27 【问题描述】:

我正在 Azure Web 应用程序中运行 ASP.NET 5 项目。

在使用大约 1.5mb 或更大的文件(表单数据)调用 API 端点时,会引发以下异常。

Here is where the exception is thrown from.

有谁知道如何解决这个问题?有没有可能的解决方法?

System.IO.InvalidDataException: Unexpected end of request content at Microsoft.AspNet.Server.Kestrel.Http.MessageBody.ForContentLength.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.FileBufferingReadStream.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.BufferedReadStream.d__39.MoveNext() --- End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.MultipartReaderStream.d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.WebUtilities.StreamHelperExtensions.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.AspNet.Http.Features.Internal.FormFeature.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.ModelBinding.FormValueProviderFactory.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.ModelBinding.CompositeValueProvider.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__49.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Mvc.Controllers.FilterActionInvoker.d__44.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Mvc.Routing.InnerAttributeRoute.d__10.MoveNext() --- End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Routing.RouteCollection.d__9.MoveNext() --- End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Builder.RouterMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ApplicationInsights.AspNet.RequestTrackingMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.IISPlatformHandler.IISPlatformHandlerMiddleware.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Hosting.Internal.RequestServicesContainerMiddleware.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Hosting.Internal.HostingEngine.<>c__DisplayClass32_0.d.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Server.Kestrel.Http.Frame.d__79.MoveNext()

【问题讨论】:

嗨,@davenewza,你解决了吗? 【参考方案1】:

我在aspnet/KestrelHttpServer 上提交了这个。它已被接受为一个错误,最近已包含在 1.0.0-rc2 里程碑中。 See issue here.

【讨论】:

【参考方案2】:

好吧,记住 ASP.NEt 5 仍然在 RC 中,所以可能在你的 VS 中当前版本更加不成熟,这个错误看起来有点奇怪,但看起来像是一个 Web 服务器错误。 asp.net 5 的 Web 服务器部分是 kestrell,它与您的堆栈跟踪匹配 Microsoft.AspNet.Server.Kestrel

我会推荐你​​

    将您的 Kestrell 服务器程序集更新为 last RC Nov 18 您的 VS 可能正在等待该更新。 如果错误仍然存​​在,请在Kestrell ASP.Net 5 GitHub 中发布问题,这可能是与其他人已经打开谈论内容长度https://github.com/aspnet/KestrelHttpServer/labels/bug 相关的错误

【讨论】:

我使用的是 RC1 包(不是 RC2 nightlies)。我提出了一个问题here。

以上是关于ASP.NET 5 RC1:System.IO.InvalidDataException:请求内容意外结束的主要内容,如果未能解决你的问题,请参考以下文章

ASP.NET Core在.NET 7 RC1中的更新

从 ASP.Net 5“空”项目中删除 Kestrel

ASP.NET 5 授权两个或多个策略(或组合策略)

ASP.Net 5 RC2 配置节绑定

防止在 asp.net 5 (vNext) 中对预检 OPTIONS 请求进行基于令牌的授权

在 ASP.Net 5 / Core 中启用跨域资源共享 (CORS)