I am working in ASP.NET MVC. I am trying to upload a file, which is successful in case of small files, but if file size is large, I get following error.
Maximum request length exceeded.
Following is my form.
@using (@Html.BeginForm("Method","Controller",FormMethod.Post,new{enctype="multipart/form-data"}))
{
<input type="file" name="file" id="file"/>
<input type="submit" value="Submit"/>
}
Following is controller method.
[HttpPost]
public ActionResult Method(HttpFileBase file)
{
string path = System.IO.Path.Combine(Server.MapPath("~/Files"), file.FileName);
file.SaveAs(path);
}
Same code works fine when file is small size i.e. of 1-2Mb, but i am trying to upload a file of 19Mb which is not being uploaded. I don't know how to specify file length and how to remove above mentioned error. Please help me.