Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpRequest.GetBufferlessInputStream not supported

Running an MVC5 application I get this error when attempting to POST back to my controller.

I is happening during the EnsureFiles() method, but I'm not trying to load any files at all.

Here is the entire stack traces

[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

My form is embarrassingly simple

@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>


}

Has anyone encountered this problem before. I got a couple of hits on the internet, but nothing that worked.

like image 703
Steven Avatar asked Mar 09 '15 18:03

Steven


2 Answers

answer to this was turning off HttpLogging in Thinktecture IdSrv.

LoggingOptions = new LoggingOptions
{
  **EnableHttpLogging = false**,
  EnableWebApiDiagnostics = true,
  IncludeSensitiveDataInLogs = true,
  WebApiDiagnosticsIsVerbose = true,
},
like image 81
Steven Avatar answered Oct 20 '22 01:10

Steven


I also got this error when adding Azure Active Directory authentication to an MVC web app that previously had no authentication.

When I moved the code below in Startup.cs from after the MVC and Web API configuration code to before it, the exception stopped occurring.

    // 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
        });
like image 20
John Mills Avatar answered Oct 20 '22 00:10

John Mills