Last post Jun 20, 2010 04:36 PM by ghootifarangi
Jun 20, 2010 05:33 AM|ghootifarangi|LINK
I'm using HttpModule to capture requests to the web server. Before
processing the page I'd like to check the values contained in some keys
of the Request.Form collection and according to some logic change if
necessary. I'd like to do this when BeginRequest event is fired. The
problem is that the Request.Form collection is readonly.
Is there any way to accomplish this task ?
Thanks is advance
Jun 20, 2010 08:03 AM|gunteman|LINK
It's usually a bad idea to do this. Your (UI) logic should handle the values, instead of changing them. If you really need to change the values, you can use reflection.
var writableMethod = Request.Form.GetType().GetMethod("MakeReadWrite", BindingFlags.NonPublic | BindingFlags.Instance);
var readOnlyMethod = Request.Form.GetType().GetMethod("MakeReadOnly", BindingFlags.NonPublic | BindingFlags.Instance);
var formField = Request.GetType().GetField("_form", BindingFlags.NonPublic | BindingFlags.Instance);
Request.Form["something"] = "value";
Jun 20, 2010 09:25 AM|ghootifarangi|LINK
Thank you very much.
Is it possible to rewrite this sample for both form and querystring?
I need a sample to replace any "a" character to "+" for any Field
in form or querystring.
Jun 20, 2010 09:57 AM|gunteman|LINK
Sure thing, but why do you really need it?
Jun 20, 2010 04:36 PM|ghootifarangi|LINK
In my language there is some character that write in two style. I want to change all of theme to correct style.