using HttpContext Class

R

Riham via .NET 247

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
 
G

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top