Posted on 2007-10-07
Last Modified: 2010-05-18
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.

Question by:peter58
    LVL 16

    Expert Comment

    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.
    LVL 4

    Author Comment

    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.
    LVL 16

    Accepted Solution

    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: -

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now