• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

HttpContext.Current

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.

Thanks
0
peter58
Asked:
peter58
  • 2
1 Solution
 
McExpCommented:
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.
0
 
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.
0
 
McExpCommented:
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: -
http://www.odetocode.com/Articles/112.aspx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now