简体   繁体   English

调用HttpRequest.GetBufferlessInputStream后,不支持此方法

[英]This method is not supported after HttpRequest.GetBufferlessInputStream has been invoked

So in an IHttpModule I am trying to grab a bufferless input stream: 所以在IHttpModule中我试图获取无缓冲输入流:

HttpContext.Current.Request.GetBufferlessInputStream(true);

But I get this error upon upload of the file I'm trying to send to a controller method: 但是我上传我试图发送到控制器方法的文件时出现此错误:

This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked.

I have already researched articles similar to these: 我已经研究过类似的文章:

https://blogs.msdn.microsoft.com/praburaj/2012/09/13/httpcontext-current-request-inputstream-property-throws-exception-this-method-or-property-is-not-supported-after-httprequest-getbufferlessinputstream-has-been-invoked-or-httpcontext-cur/ https://blogs.msdn.microsoft.com/praburaj/2012/09/13/httpcontext-current-request-inputstream-property-throws-exception-this-method-or-property-is-not-supported-after-的HttpRequest-getbufferlessinputstream-已-被调用的或-的HttpContext-CUR /

How should I use HttpRequest.GetBufferlessInputStream? 我应该如何使用HttpRequest.GetBufferlessInputStream?

But the add key app setting doesn't seem to make a difference. 但添加键应用程序设置似乎没有什么区别。

Here is my stacktrace: 这是我的堆栈跟踪:

[HttpException (0x80004005): This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked.]
   System.Web.HttpRequest.EnsureFiles() +3678728
   System.Web.HttpRequest.get_Files() +13
   System.Web.HttpRequestWrapper.get_Files() +28
   System.Web.Mvc.HttpFileCollectionValueProvider.GetHttpPostedFileDictionary(ControllerContext controllerContext) +36
   System.Web.Mvc.HttpFileCollectionValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +30
   System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +69
   System.Web.Mvc.ControllerBase.get_ValueProvider() +30
   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +62
   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
   System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159

Try using: 尝试使用:

var a = Request.Content.ReadAsByteArrayAsync();

a.Result returns the byte array which then you can use to convert to something you need. a.Result返回字节数组,然后您可以使用它转换为您需要的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在调用HttpRequest.GetBufferlessInputStream之后,不支持此方法或属性 - This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked 在.NET 4.5.2中将.asmx添加到Nancy-在HttpRequest.GetBufferlessInputStream之后不支持 - Adding .asmx to Nancy in .NET 4.5.2 - not supported after HttpRequest.GetBufferlessInputStream 我应该如何使用 HttpRequest.GetBufferlessInputStream? - How should I use HttpRequest.GetBufferlessInputStream? 在Silverlight中调用事件后,是否有理由从事件中删除方法? - Is there a reason to remove a method from an event after it has been invoked in Silverlight? 在.NET中有一种方法可以在调用另一个方法之后但在输入之前自动调用一个方法 - Is there a way in .NET to have a method called automatically after another method has been invoked but before it is entered Visual C#在调用Click事件后立即将其删除 - Visual C# removing a Click event directly after it has been invoked C#当另一个类中的静态方法被调用时,如何通知一个类(简单的是/否)? - C# How to notify a class (simple true/false) when a static method in another class has been invoked? 如何在渲染页面后立即执行方法? - How to execute a method right after a Page has been rendered? 方法不支持翻译成SQL - Method has no supported translation to SQL C# 方法有 1 个参数,但使用 2 个参数调用 - C# Method has 1 parameter but is invoked with 2 arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM