Home Why can't I access FileName of uploaded file in ASP.NET MVC when uploaded using Microsoft Edge?
Reply: 0

Why can't I access FileName of uploaded file in ASP.NET MVC when uploaded using Microsoft Edge?

user1030
1#
user1030 Published in July 16, 2018, 6:37 am

I have a simple file upload page and an ASP.NET MVC Controller to process the uploaded file. In Chrome and Firefox, everything works as expected. But it seems that Edge uploads the file differently, such that the Controller sees that a file has been uploaded, but shows FileName as "" and ContentLength as 0.

Here is the cshtml:

@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <h3>Upload File</h3>
    File:
    <input type="file" name="UploadedFile" />
    <input type="submit">Submit</button>
}

And in the controller I have:

HttpPostedFileBase file = Request.Files["UploadedFile"];

Afterward the file object is not null, but its ContentLength is 0 and FileName is an empty string. With Chrome and Firefox, these values contain the correct data.

What is different about how Edge handles file uploads?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313426 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO