c# - Is it possible to obtain Request Body via Application_BeginRequest? -
just stated title; researching didn't find specifics on retrieving full request body post. ideas if possible, need populate server variable iis.
i have following code:
private void application_beginrequest(object source, eventargs e) { httpapplication application = (httpapplication)source; bindingflags temp = bindingflags.nonpublic | bindingflags.instance | bindingflags.static; methodinfo addstatic = null; methodinfo makereadonly = null; methodinfo makereadwrite = null; type type = application.request.servervariables.gettype(); methodinfo[] methods = type.getmethods(temp); foreach (methodinfo method in methods) { switch (method.name) { case "makereadwrite": makereadwrite = method; break; case "makereadonly": makereadonly = method; break; case "addstatic": addstatic = method; break; } } makereadwrite.invoke(application.request.servervariables, null); //goal retrieve request body populate server variable, display via iis. //my current use of application.request.form doesn't work of course. string[] values = { "requestformparams", application.request.form.tostring() }; addstatic.invoke(application.request.servervariables, values); makereadonly.invoke(application.request.servervariables, null); }
Comments
Post a Comment