1234567890
1234567890

Reputation: 43

asp.net FileUploadControl rejects larger files

protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUploadControl.HasFile)
    {
        try
        {
            string filename = Path.GetFileName(FileUploadControl.FileName);
            FileUploadControl.SaveAs(Server.MapPath("~/Files/") + filename);
            StatusLabel.Text = "Upload status: File uploaded!";
            String x = Server.MapPath("~/Files/") + filename;
        }
        catch (Exception ex)
        {
            StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
        }
    }
}

In this simple example, when I try file that is under 1MB, it works well, but if I try 10MB, i get "This site can’t be reached The connection was reset." Which is browser message.

So where's the problem?

Upvotes: 1

Views: 57

Answers (1)

Backs
Backs

Reputation: 24913

Check your web.config file (10mb and 5 minutes):

<system.web>
  <httpRuntime maxRequestLength="102400" executionTimeout="300"/>
</system.web>

Upvotes: 2

Related Questions