Hi Guys

I am using the Httpcontext.current class to access the request and response object and I was just wondering if there are any issues with it like not getting the right pages request and response object.

Who is Participating?
McExpConnect With a Mentor Commented:
The short answer is yes if you get a non-null response from HttpContext.current it "Should" be the one you where expecting, I'm sure there are ways that you can write bad code which would fail. The article below makes some good points about why you should not be using the context object unless you have to!

For a full description of how HttpContext.current works see: -
Maybe you could provide some more info?

Where are you geting the refrence to the HttpContext?

You can't (shouldn't) create an instance of the Httpcontext.current class, if you are getting the context from a Parent Page (this.Page.Context) of a user control or something similar you will always get the correct one for the control in quesiton.
peter58Author Commented:
I have a simple "functions" class in my website which has some shared functions in which I call from most of my webpages. The function in the class uses the httpcontext.current to get some cookie info.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.