Base solution for your next web application
Open Closed

Timeouts are not supported on this stream. #1426


User avatar
0
soulmate created

Hello,

I have implemented a multi file upload based on a Kendo UI component. Here is my method:

[DisableAuditing]
        public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> files, int offerId)
        {
...
}

It worked without any problem. However, I upgraded to v0.10.0.2 and now I receive following error:

Server Error in '/' Application.

Timeouts are not supported on this stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Timeouts are not supported on this stream.

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:

[InvalidOperationException: Timeouts are not supported on this stream.] System.IO.Stream.get_ReadTimeout() +57

[TargetInvocationException: Property accessor 'ReadTimeout' on object 'System.Web.HttpInputStream' threw the following exception:'Timeouts are not supported on this stream.'] System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +525 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:192 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:185 Abp.Runtime.Validation.Interception.MethodInvocationValidator.ValidateObjectRecursively(Object validatingObject) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:154 Abp.Runtime.Validation.Interception.MethodInvocationValidator.Validate() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:85 Abp.Web.Mvc.Validation.AbpMvcValidationFilter.OnActionExecuting(ActionExecutingContext filterContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Validation\AbpMvcValidationFilter.cs:27 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +268 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +1079 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +1079 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +93 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters, AsyncCallback callback, Object state) +292 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +1167 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +455 System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +42 System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +67 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +897 System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +711 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +94 System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +67 System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +170 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +575 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +923 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

How can I fix this one?


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share full of your code for UploadFiles if it is possible ?

  • User Avatar
    0
    soulmate created

    Yes, here is the code. However, the code is not hit at any time, so I think where is a filter or something like that before that prevents the execution:

    [DisableAuditing]
            public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> files, int offerId)
            {
                // The Name of the Upload component is "files"
                if (files != null)
                {
                    foreach (var file in files)
                    {
                        var offerFile = new OfferFile();
                        var fileName = Path.GetFileName(file.FileName);
    
                        //Check if file exist
                        offerFile = _offerFileService.GetByNameAndOfferId(fileName, offerId) ?? new OfferFile();
    
                        offerFile.Name = fileName;
                        offerFile.FileType = file.ContentType;
                        offerFile.OfferId = offerId;
                        using (var binaryReader = new BinaryReader(file.InputStream))
                        {
                            offerFile.File = binaryReader.ReadBytes(file.ContentLength);
                        }
    
                        //Save
                        _offerFileService.Save(offerFile);
                    }
                }
    
                // Return an empty string to signify success
                return Content("");
            }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    What was the previous version before v0.10.0.2 you were using ?

  • User Avatar
    0
    soulmate created

    0.9.3

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your data sent to UploadFiles from client if it is possible. I couldn't reproduce the error.

  • User Avatar
    0
    soulmate created

    Of cause, it is based on the kendo upload control. It is strange, the code worked perfectly before. The method I describe above is never hit, so I think there is a new filter or something that blocks the request

    @(Html.Kendo().Upload()
              .Name("files").TemplateId("fileTemplate")
    
              .Async(a => a
                  .Save("UploadFiles", "OfferFile", new { offerId = Model.OfferId })
                  .Remove("RemoveFiles", "OfferFile", new { offerId = Model.OfferId })
                  .AutoUpload(true)
              )
              .Files(files =>
              {
                  foreach (var f in Model.Files)
                  {
                      files.Add().Name(f.Name).Extension(f.FileType);
                  }
              })
        )
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry for long delay on this issue.

    Abp is trying to validate MVC Action parameters and when tries to read value of your files parameter to validate it, this exception occurs.

    You can ignore HttpPostedFileWrapper types for validation like below and it will fix your issue. Place this code in your Global.asax's application start,

    MethodInvocationValidator.IgnoredTypesForRecursiveValidation.AddIfNotContains(typeof(HttpPostedFileWrapper));