Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing HttpContext

I've got a project which as a reference added to System.Web.

However, it can't seem to pick up HttpContext. Doing this:

Imports System.Web
_ApplicationBase = HttpContext.Current()

Tells me that HttpContext is not declared. If you look at the methods and properties inside System.Web there are hardly any showing: only AspHostingPermission, AspHostingPermissionAttribute, AspHostingPermissionLevel and Services.

The reference is valid and pointing to the right place. This is driving me crazy - what have I missed?

Cheers, Matt

like image 423
Bob Tway Avatar asked Dec 17 '22 01:12

Bob Tway


2 Answers

If this error is happening at design time then it's a case of a missing assembly reference. Make sure your project is referencing the System.Web.dll assembly.

like image 111
Keith Avatar answered Jan 03 '23 05:01

Keith


An HttpContext object exists only during an asp.net request on the thread that is processing the request. In any other thread or process, there is no HttpContext available.

like image 25
Pent Ploompuu Avatar answered Jan 03 '23 04:01

Pent Ploompuu