using HttpContext Class

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default using HttpContext Class

    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 ([url]http://www.dotnet247.com/[/url])

    <Id>j+6juX7DXEijP0Hp/Pl5pg==</Id>
    Riham via .NET 247 Guest

  2. Similar Questions and Discussions

    1. httpcontext HELP
      The issue is that I want to maintain the login without asking the user to login back to the application in case the session times out.....and how do...
    2. HttpContext
      Hello, i searched 2days for a solution and maybe someone can help me. I'm programmin' a C# Assemblie and don't know which class I should use...
    3. HttpContext items and one-way methods
      Hi, I try to put some custom objects into HttpContext.Current.Items collection in one-way webmethod, but they seem not to be there in another...
    4. HttpContext.Current
      Now how in the wolrd does that work? How does it know that some static method I called on some library was called by a page that had that context?...
    5. Questions on HttpContext
      Hello ALL! It is known that there's a HttpContext class in dotnet framework which provides variable sharing. I have two questions that i can...
  3. #2

    Default Re: using HttpContext Class

    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" <anonymous@dotnet247.com> wrote in message
    news:OnzCJ4TJEHA.3264@tk2msftngp13.phx.gbl...
    > 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 ([url]http://www.dotnet247.com/[/url])
    >
    > <Id>j+6juX7DXEijP0Hp/Pl5pg==</Id>

    Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139