IrishChieftain
IrishChieftain

Reputation: 15262

VS 2010 Intellisense Issue

I'm working on a C# library class which is being consumed by an ASP.NET 4.0 Web Forms application. In my class, I'm trying to access the HttpRequest.Application object as described here:

http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

This documentation says it is in the System.Web namespace but even when I add a reference in my library project, it is still not available to me.

The only way I can get to the ApplicationPath property is by using:

HttpContext.Current.Request.ApplicationPath;

What's going on?

Upvotes: 1

Views: 194

Answers (1)

rsbarro
rsbarro

Reputation: 27369

ApplicationPath is not a static property on HttpRequest, which is why you have to access it using the instance HttpContext.Current.Request. If you don't want to use HttpContext.Current.Request you could always pass the HttpRequest object in to your class library from your ASP.NET web forms.

For example (from your Page_Load):

protected void Page_Load(object sender, EventArgs e)
{
    var myClass = new MyClass();
    myClass.MyMethod(this.Request);
}

Upvotes: 3

Related Questions