This project has moved. For the latest updates, please go here.

Why you used reflection?

Topics: General Discussion
Aug 2, 2011 at 2:42 PM

Hi,

Can you explain me why you used reflection on the HTTP handler? Why you need to do that?

Coordinator
Aug 3, 2011 at 7:14 AM

Hi,
In order to get the HttpWorker from HttpContext and set it back to null to terminate it on HttpContext

Coordinator
Aug 3, 2011 at 7:28 AM

CheloXL:

It's necessary to use reflection in order to make it work.

Oct 31, 2012 at 2:22 PM

Very nice example. I didn't knew that you can read the request content with an http handler before the ASP.NET would read it completely...I thought you can do that only with httpmdoules and currently we have a client who does not want to use  http modules so I will try the httphandler approach.

Code to avoid reflection in order to get the HttpWorkerRequest (I'm already using it and it works well):

IServiceProvider provider = (IServiceProvider)HttpContext.Current;
return (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));