public ActionResult Upload() { string message = null; if (Request.QueryString["FileTooLarge"] != null) { int maxRequestLength = 0; System.Web.Configuration.HttpRuntimeSection section = (System.Web.Configuration.HttpRuntimeSection) System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.web/httpRuntime"); if (section != null) { maxRequestLength = section.MaxRequestLength; } message = string.Format("File is too large. Use multiple file upload for files larger than {0}KB.", maxRequestLength); } var model = new BlobUploadModel { UploadHandler = this.GetUploadHandlerPage(), Message = message }; return(this.View(model)); }
public int GetMaxRequestLength() { // presume that the section is not defined in the web.config int defaultSize = 4096; System.Web.Configuration.HttpRuntimeSection section = System.Configuration.ConfigurationManager.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection; if (section != null) { defaultSize = section.MaxRequestLength; } return(defaultSize); }
private string get_content() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.Web.Configuration.HttpRuntimeSection htc = new System.Web.Configuration.HttpRuntimeSection(); sb.AppendFormat("var {0} = '{1}';", "webroot", HttpUtility.JavaScriptStringEncode(Settings.Paths.WebRoot)); sb.AppendFormat("var {0} = {1};", "maxHttpLength", htc.MaxRequestLength * 1024); sb.AppendFormat("var {0} = {1};", "maxFileLength", Settings.ApplicationSettings.MaximumFileSize); return(sb.ToString()); }
private string get_content() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.Web.Configuration.HttpRuntimeSection htc = new System.Web.Configuration.HttpRuntimeSection(); sb.AppendFormat("var {0} = '{1}';", "webroot", HttpUtility.JavaScriptStringEncode(Settings.Paths.WebRoot)); sb.AppendFormat("var {0} = {1};", "maxHttpLength", htc.MaxRequestLength * 1024); sb.AppendFormat("var {0} = {1};", "maxFileLength", Settings.ApplicationSettings.MaximumFileSize); return sb.ToString(); }
/// <summary> /// Gets the maximum request length from the configuration settings. /// </summary> /// <param name="context">Http context.</param> /// <returns>The maximum request length (in kb).</returns> int GetMaxRequestLength(HttpContext context) { int DEFAULT_MAX = 4096; // Look up the config setting System.Web.Configuration.HttpRuntimeSection config = context.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection; if (config == null) { return(DEFAULT_MAX); // None found. Return the default setting. } else { return(config.MaxRequestLength); } }
public void Page_PreInit(object sender, EventArgs e) { var httpRuntimeSection = new System.Web.Configuration.HttpRuntimeSection(); var settings = GetSettings(); if (settings.MaxRequestLength > 0) { httpRuntimeSection.MaxRequestLength = settings.MaxRequestLength; } WebFormHelper.ClearIncludesList(); PreloadHelper.PreloadList.Clear(); if (AppSettings.UseLoadFileServiceUrl) { WebFormHelper.LoadFileServiceUrl = AppSettings.FileServiceHandlerUrl + AppSettings.LoadFileUriSegment; } else { WebFormHelper.LoadFileServiceUrl = ""; } WebFormHelper.CombineCssAndJsIncludes = AppSettings.CombineCssAndJsIncludes; if (Request["action"] != null) { switch (Request["action"].ToLower()) { case "clearcache": ContextHelper.ClearAllMemoryCache(); break; case "logout": FormsAuthentication.SignOut(); break; } } if (this.MasterPageFile != null) { var masterFilePath = GetMasterPageFilePath(); if (File.Exists(URIHelper.ConvertToAbsPath(masterFilePath))) { MasterPageFile = masterFilePath; } else { MasterPageFile = ""; } } if (currentPageVirtualPath == "") { currentPageVirtualPath = URIHelper.GetCurrentVirtualPath(); } if (FrameworkSettings.Current?.CurrentMediaDetail == null) { return; } if (currentPageVirtualPath == "") { currentPageVirtualPath = URIHelper.GetCurrentVirtualPath(); } if (!CanAccessSection()) { FormsAuthentication.RedirectToLoginPage(); return; } }