This is using ASP.NET 2.0 in an IIS 6 world.
I have a user submitting a form that sends the data to be via POST. The page receiving the data does some simple validations. If validation passes, then a black-box code routine runs that basically reads the data using Request.Form(“NameHere”).
I’d like to be able to change the value of the POST item and then put it back on the POST. I don’t have the ability to modify the code that reads the Request.Form(“NameHere”), so my work around idea is to modify the data during the page’s load event. If I change the value of the POST item, then the black-box code doesn’t have to be modified.
Is it possible to change the value of an item on the HTTP POST?
Has anyone done this?
Thanks!
Even though it is a bit hacky, there is a way to change the value of a POST variable.
We can use Reflection to mark the
Request.Formcollection as non-readonly, change the value to what we want and mark it back as readonly again (so that other people cannot change values). Use the following function:I have tested the code on my machine and it works fine. However, I cannot give any performance or portability guarantees.