No Files Returned to Controller

4 posts, 0 answers
  1. Arie
    Arie avatar
    16 posts
    Member since:
    Jun 2014

    Posted 26 Oct Link to this post

     

    We are currently working with the Upload control in what would seem to be a very simple setup.

    @(Html.Kendo().Upload()
                                .Name("files")
                                .ShowFileList(false)
                                .Multiple(false)
                                .Async(a => a
                                     .Save("Save", "Patient")
                                     .AutoUpload(true)
                                     .SaveField("files")
                                  )
                                .Validation(validation => validation.AllowedExtensions(new string[] { ".gif", ".jpg", ".png" }))
                                  )

     

     

    and our controller is defined as such

    [HttpPost]
    public async Task<IActionResult> Save(IEnumberable<HttpPostedFileBase> files)

     

    What is happening is that the files parameter is not null but has a count of 0. This is in an ASP.NET core MVC app.

    What could the issue be? Is there something simple we are missing here?

    Thanks
    AJ

     

     

     

     

  2. Eduardo Serra
    Admin
    Eduardo Serra avatar
    50 posts

    Posted 26 Oct Link to this post

    Hello Arie,

    This issue often occurs because the name of the widget doesn't match the name of the parameter received by the controller, but they match in your case so we're good on that front.

    I noticed that instead of IEnumerable you're setting the type as IEnumberable, with an extra B; let's fix that and see if the problem keeps occurring.

    Thank you.

    Regards,
    Eduardo Serra
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Arie
    Arie avatar
    16 posts
    Member since:
    Jun 2014

    Posted 26 Oct in reply to Eduardo Serra Link to this post

    That's just a typo. Yes the problem is still present.

     

    I have also tried List but it has the same problem.

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    278 posts

    Posted 28 Oct Link to this post

    Hi Arie,

    In order the Upload to work properly, the HttpPostedFileBase class should implement the Microsoft.AspNetCore.Http.IFormFileinterface.

    Also, you may have to return an ActionResult, instead of the asynchronous Task<IActionResult>:
    public ActionResult Save(IEnumberable<HttpPostedFileBase> files)

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready