get the max request length in web.config OR set the max request length programatically

Posted on 2006-05-26
Last Modified: 2008-01-09
Greetings Experts,
In my web.config, I've set the max request length like this:
    <httpRuntime maxRequestLength="2048"/>
and I want to fetch that value in code like this:
Dim iMaxRequestLength = ???

Or another thing that would solve my problem would be to programatically set the max request length in code

Is it possible to perform such a task?
Question by:ID3TECH
    LVL 5

    Accepted Solution



    Dim myWebConfigXmlDoc As New XmlDocument
            Dim myXmlNode As XmlNode

            myWebConfigXmlDoc.Load(Path.GetDirectoryName(Request.PhysicalApplicationPath) & "/" & "web.config")

            myXmlNode = myWebConfigXmlDoc.SelectSingleNode("//configuration/system.web/httpRuntime/@maxRequestLength")

            myXmlNode.InnerText = "1232323"  'Give new value to be set

            myWebConfigXmlDoc.Save(Path.GetDirectoryName(Request.PhysicalApplicationPath) & "/" & "web.config")

    But before this..just ensure u have give read/write access for the virtual directory to the local user ..

    Hope this helps u

    LVL 26

    Expert Comment

    >>Is it possible to perform such a task?
    not possible t change values in web.config at runtime

    now the question is y do u want to get that value from web.config and is this framework 1.1. or 2 .. ie.. VS2005 has inbiult functionalities to do it .. else the aboev solution should work


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now