ASP.NET MVC Request.Files empty

Trying to get File uploads to work in ASP.NET MVC but Request.Files is always empty?

There a few things you might have done wrong!

The form tag must have enctype=”multipart/form-data” and your file input tag must have a name not just an id like below.

<% using(Html.BeginRouteForm("submission_create_path", FormMethod.Post,
 new { enctype = "multipart/form-data" })) { %>
    <input id="sourceCode" name="sourceCode" type="file" />
    <input type="submit" value="Upload" />
<% } %>

1 Response to “ASP.NET MVC Request.Files empty”


Leave a Reply