Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2006-05-26
Medium Priority
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

Accepted Solution

vinodhsomasekharan earned 2000 total points
ID: 16774197


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 asp.net user ..

Hope this helps u

LVL 26

Expert Comment

ID: 16774551
>>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


Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

572 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