HTTP Error 400 - Bad Request due to FileUpload con

2019-07-20 18:22发布

I have a web form(.net framework 4) which contains a submit button and a FileUpload control.When I debug the website from visual studio 2010, the form appears as intended.When I upload a file with size > 438k(as per my observations.Actual value of maximum file size is unknown,but for file with size 200K, it is working),I get the following error on clicking the button.

Server Error in '/Dpp2012New' Application.
HTTP Error 400 - Bad Request.
Version Information: ASP.NET Development Server 10.0.0.0 

When I upload a file with size less than above limit, code functions as usual. The onclick event handler codebehind is:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    If FileUpload1.HasFile Then
        MsgBox("Has file!")
    End If
End Sub

After scratching through the net(this SO post), I added this in web.config:

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

This should have solved the issue.But it does not. Any help to solve the problem would be highly appreciated.

1条回答
可以哭但决不认输i
2楼-- · 2019-07-20 19:01

Please debug your site and check whether you are connected to the database ? I think you are not connected. If you are facing a problem in uploading large files then you must add the following attribute to your webconfig file.

<system.web> 
<httpRuntime executionTimeout="110" maxRequestLength="20000" /> 
</system.web>

maxRequestLength is the maximum file size.

Updated Answer: Run your site on a different browser like google chrome, Internet explorer.

查看更多
登录 后发表回答