using HttpContext Class

Discussion in 'ASP .Net Security' started by Riham via .NET 247, Apr 18, 2004.

  1. I'm trying to get the PathInfo propert for the current URL request in a class file, but I can't get it to work.
    Here's what I've tried so far:

    using System.Web;

    String PathInfo;
    PathInfo = HttpContext.Current.Request.PathInfo();

    I've also tried "using System.Web.HttpContext;"

    It gives me the following error:
    "The type or namespace name 'HttpContext' could not be found (are you missing a using directive or an assembly reference?)"

    Would you please help me know where the problem is?

    Thanks,
    Riham

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>j+6juX7DXEijP0Hp/Pl5pg==</Id>
     
    Riham via .NET 247, Apr 18, 2004
    #1
    1. Advertising

  2. Riham via .NET 247

    Guest Guest

    That is because HttpContext is the Class name.
    If you are in web page then the HttpContext for the current page will be
    called Context
    eg Context or this.Context. or if you are in a UserControl/Web Control
    this.Page.Context


    If you are attempting to use the Context from another class you have to make
    sure that the class has a reference either to the Context or the Parent Page


    Hope this helps - posting is provided as is

    "Riham via .NET 247" <> wrote in message
    news:...
    > I'm trying to get the PathInfo propert for the current URL request in a
    > class file, but I can't get it to work.
    > Here's what I've tried so far:
    >
    > using System.Web;
    >
    > String PathInfo;
    > PathInfo = HttpContext.Current.Request.PathInfo();
    >
    > I've also tried "using System.Web.HttpContext;"
    >
    > It gives me the following error:
    > "The type or namespace name 'HttpContext' could not be found (are you
    > missing a using directive or an assembly reference?)"
    >
    > Would you please help me know where the problem is?
    >
    > Thanks,
    > Riham
    >
    > -----------------------
    > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    > <Id>j+6juX7DXEijP0Hp/Pl5pg==</Id>
     
    Guest, Apr 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Newton
    Replies:
    0
    Views:
    2,947
    Mike Newton
    Jul 23, 2004
  2. Steve Franks
    Replies:
    3
    Views:
    1,259
    Scott Allen
    Jul 9, 2005
  3. Guest
    Replies:
    2
    Views:
    1,183
    Steven Cheng[MSFT]
    Aug 17, 2005
  4. E11
    Replies:
    1
    Views:
    4,897
    Thomas Weidenfeller
    Oct 12, 2005
  5. Tony

    Dim context As HttpContext = HttpContext.Current

    Tony, Mar 2, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    328
    Teemu Keiski
    Mar 3, 2004
Loading...

Share This Page