ASP.NET file upload size limit – simple solution

Using Global.asax file

public class Global : System.Web.HttpApplication{    protected void Application_Start(object sender, EventArgs e)    {    }    protected void Session_Start(object sender, EventArgs e)    {    }    protected void Application_BeginRequest(object sender, EventArgs e)    {    }    protected void Application_AuthenticateRequest(object sender, EventArgs e)    {    }    protected void Application_Error(object sender, EventArgs e)    {        Exception currentException = Server.GetLastError();        string RequestedUrl = string.Empty;        try        {            //RequestedUrl = HttpUtility.UrlDecode(HttpUtility.UrlEncode(Request.Url.PathAndQuery));            RequestedUrl = HttpUtility.UrlDecode(HttpUtility.UrlEncode(Request.RawUrl));        }        catch        {            RequestedUrl = string.Empty;        }        if (((currentException) is System.Web.HttpException))        {            if (currentException.GetBaseException().Message.StartsWith("Maximum request length exceeded"))            {                Response.Redirect(string.Format("~/{0}&E=FTL", RequestedUrl));            }        }    }    protected void Session_End(object sender, EventArgs e)    {    }    protected void Application_End(object sender, EventArgs e)    {    }}

Leave a Reply

Your email address will not be published. Required fields are marked *