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

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?
ID3TECHAsked:
Who is Participating?
 
vinodhsomasekharanCommented:

Hai,

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

Regards
vinu
0
 
RejojohnyCommented:
>>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

Rejo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.