lundi 21 juin 2021

How can I set value to readonly Httpcontex.request.HttpMethod?

I am trying to write testcases for a method and I want to set value to HTTPMethod, I am trying to use Reflection to do this but I'm getting object reference set to null, let me know how can I overcome this obstacle.

PFB Sample Code snippet.

HttpWorkerRequest httpWorkerRequest = new SimpleWorkerRequestHelper(false, "153.40.12.148", "/siteminderagent/forms/login.fcc", "Mozilla/4.0 (compatible; MSIE 7.0)")

HttpContext httpContext = new HttpContext(httpWorkerRequest);

typeof(HttpRequest).GetField("HttpMethod", BindingFlags.Instance).SetValue(httpContext, "POST");




Aucun commentaire:

Enregistrer un commentaire