1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| private void AddRequestFields()
{
string s_transaction_id = HttpContext.Current.Request[FINISHED_TRANSACTION_KEY];
NameValueCollection fields = HttpContext.Current.Cache.Get(s_transaction_id + "-" + FINISHED_FIELDS_KEY) as NameValueCollection;
if (fields != null)
{
BindingFlags eFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Assembly webAssembly = typeof(HttpRequest).Assembly;
Type t = webAssembly.GetType("System.Web.HttpValueCollection");
// Récupérer la référence vers la méthode MakeReadWrite.
MethodInfo m = t.GetMethod("MakeReadWrite", eFlags);
NameValueCollection formFields = HttpContext.Current.Request.Form;
m.Invoke(formFields, null);
foreach (string key in fields)
{
formFields[key] = fields[key];
}
// Récupérer la référence vers la méthode MakeReadOnly.
m = t.GetMethod("MakeReadOnly", eFlags);
m.Invoke(formFields, null);
}
} |