VS 2010 Intellisense Issue
本文关键字:Issue Intellisense 2010 VS | 更新日期: 2023-09-27 18:00:06
我正在开发一个C#库类,该类正被ASP.NET 4.0 Web Forms应用程序使用。在我的课堂上,我试图访问HttpRequest.Application对象,如下所述:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx
这个文档说它在System.Web命名空间中,但即使我在库项目中添加引用,它仍然不可用
我可以访问ApplicationPath属性的唯一方法是使用:
HttpContext.Current.Request.ApplicationPath;
怎么回事?
ApplicationPath
不是HttpRequest
上的静态属性,这就是为什么必须使用实例HttpContext.Current.Request
访问它。如果您不想使用HttpContext.Current.Request
,您可以始终将HttpRequest
对象从ASP.NET web窗体传递到类库中。
例如(从Page_Load):
protected void Page_Load(object sender, EventArgs e)
{
var myClass = new MyClass();
myClass.MyMethod(this.Request);
}