I will stick my neck out and say that the documentation is mistaken.
Page developers can use the HttpRuntime class properties to find out
information about the current application domain for diagnostic purposes, for example.
The HttpRuntime object is used at the beginning of the
ASP.NET pipeline model that processes HTTP requests.
The ProcessRequest method drives all subsequent ASP.NET Web processing.
Since, if you change any httpruntime property, the result would need to be
handled by a new process, you can't get there from here if you attempt to
change, on the fly, the httpruntime's operational parameters.
My curiosity was piqued by your experience, so I tested the scenario.
Sure enough, I could, apparently, change the MaxRequestLengt h property.
But, just like you reported, the upload procedure failed
Here's what I used :
Sub Page_Load(obj as object, e as eventargs)
Dim httpConfig As HttpRuntimeSect ion = New HttpRuntimeSect ion
lblMaxRequestLe ngth.Text = httpConfig.MaxR equestLength
httpConfig.MaxR equestLength = 8192
lblMaxRequestLe ngth2.Text = httpConfig.MaxR equestLength
End Sub
Sub Button1_Click(s ender As Object, e As EventArgs)
If FileUpLoad1.Has File
FileUpLoad1.Sav eAs("C:\" & FileUpLoad1.Fil ename)
Label1.Text = "Received " & FileUpLoad1.Fil eName & " Content Type " _
& FileUpLoad1.Pos tedFile.Content Type & " Length " & FileUpLoad1.Pos tedFile.Content Length
Else
Label1.Text = "No file was uploaded"
End If
End Sub
When the page loads, lblMaxRequestLe ngth reports that MaxRequestLengt h is 4096,
and lblMaxRequestLe ngth2 reports that MaxRequestLengt h ( changed in Page_Load )
is 8192, but when I tried uploading a 6MB file, the process failed.
An automatic AppDomain restart should occur when any httpRuntime parameter is modified.
The problem, of course, is that when the AppDomain restarts, it goes right back
to the default httpruntime parameters specified in web.config or machine.config.
It looks like you found a documentation error.
If you feel strongly enough about this, bug it at the Feedback Center:
http://connect.microsoft.com/feedbac...spx?SiteID=210
Juan T. Llibre, asp.net MVP
aspnetfaq.com :
http://www.aspnetfaq.com/
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
=============== =============== =====
"salty" <sa***@discussi ons.microsoft.c omwrote in message
news:30******** *************** ***********@mic rosoft.com...
"Juan T. Llibre" wrote:
>re:
So it was great to see the .NET Framework 2.0 now allegedly supports this in the page.
I'm not so sure that's true.
[...]
Where did you read that changing the
httpRuntime' s MaxRequestLengt h can be done at the page level ?
Here:
http://msdn2.microsoft.com/en-us/lib...estlength.aspx
MaxRequestLengt h is a public property of the HttpRuntimeSect ion Class
described here:
http://msdn2.microsoft.com/en-us/lib...n_members.aspx
Unless I'm completely misunderstandin g what I'm reading, in which case my
complaint about MS's documentation remains.