Maximum request length exceeded.

前端 未结 14 2775
臣服心动
臣服心动 2020-11-21 07:37

I am getting the error Maximum request length exceeded when I am trying to upload a video in my site.

How do I fix this?

14条回答
  •  青春惊慌失措
    2020-11-21 08:01

    And just in case someone's looking for a way to handle this exception and show a meaningful explanation to the user (something like "You're uploading a file that is too big"):

    //Global.asax
    private void Application_Error(object sender, EventArgs e)
    {
        var ex = Server.GetLastError();
        var httpException = ex as HttpException ?? ex.InnerException as HttpException;
        if(httpException == null) return;
    
        if (((System.Web.HttpException)httpException.InnerException).WebEventCode == System.Web.Management.WebEventCodes.RuntimeErrorPostTooLarge)
        {
            //handle the error
            Response.Write("Too big a file, dude"); //for example
        }
    }
    

    (ASP.NET 4 or later required)

提交回复
热议问题