Click here to Skip to main content
12,629,107 members (36,431 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#3.5
<location path="RegistrationPage2.aspx">
        <system.web>
            <httpRuntime executionTimeout="240" maxRequestLength="2097152" />
              </system.web>
       </location>




Here how to access maxrequest length value into code behind file for display the warning message "The maximum file size is 2MB!".


Please give the code to display the warning message if the file size is above 2MB.
Posted 30-Aug-12 0:58am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

var section = HttpContext.Current.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection;

will get you httpRuntime settings for currently executing page.

Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Default.aspx");
HttpRuntimeSection o = config.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

will get you settings for a given virtual path.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100