不支持HttpRequest.GetBufferlessInputStream

时间:2015-03-09 18:55:38

标签: asp.net-mvc-5

运行MVC5应用程序尝试POST回我的控制器时出现此错误。

我在EnsureFiles()方法期间发生了这种情况,但我根本没有尝试加载任何文件。

这是整个堆栈跟踪

[HttpException (0x80004005): This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked.]
System.Web.HttpRequest.EnsureFiles() +3274885
System.Web.HttpRequest.get_Files() +12
System.Web.HttpRequestWrapper.get_Files() +28
System.Web.Mvc.HttpFileCollectionValueProvider.GetHttpPostedFileDictionary(ControllerContext controllerContext) +120
System.Web.Mvc.HttpFileCollectionValueProvider..ctor(ControllerContext controllerContext) +51
System.Web.Mvc.HttpFileCollectionValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +117
System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +160
System.Web.Mvc.ControllerBase.get_ValueProvider() +85
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +154
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +199
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +1680
System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +59
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +94
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +559
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +82
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +105
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +588
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +47
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +65
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +139
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +484
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +98
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +106
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +446
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

我的表格非常简单

@using (Html.BeginForm())
{
<div class="form-group">
    In order to continue you must change your password.
</div>

<div class="form-group">
    @Html.LabelFor(x=> Model.OldPassword)
    @Html.TextBoxFor(x=> Model.OldPassword)
</div>

<div class="form-group">
    @Html.LabelFor(x => Model.NewPassword)
    @Html.TextBoxFor(x => Model.NewPassword)
</div>

<div class="form-group">
    @Html.LabelFor(x => Model.NewPasswordConfirm)
    @Html.TextBoxFor(x => Model.NewPasswordConfirm)
</div>

<div class="form-group">
    <input type="submit" class="btn btn-primary" value="Submit" /> 
    <input type="reset" class="btn btn-danger" value="Cancel" />
</div>


}

之前有没有人遇到过这个问题。我在网上得到了几个点击,但没有任何效果。

2 个答案:

答案 0 :(得分:4)

这回答了关闭Thinktecture IdSrv中的HttpLogging。

LoggingOptions = new LoggingOptions
{
  **EnableHttpLogging = false**,
  EnableWebApiDiagnostics = true,
  IncludeSensitiveDataInLogs = true,
  WebApiDiagnosticsIsVerbose = true,
},

答案 1 :(得分:2)

将Azure Active Directory身份验证添加到以前没有身份验证的MVC Web应用程序时,我也遇到了此错误。

当我将 MVC和Web API配置代码之后的中的Startup.cs中的代码移动到之前的时,异常停止发生。

    // Microsoft Azure Active Directory
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
    app.UseCookieAuthentication(new CookieAuthenticationOptions());
    app.UseOpenIdConnectAuthentication(
        new OpenIdConnectAuthenticationOptions
        {
            ClientId = appSettings.IdaClientId,
            Authority = appSettings.IdaAuthority,
            PostLogoutRedirectUri = appSettings.IdaPostLogoutRedirectUri
        });