Missing HttpContext

I have a project that is added as a link to System.Web.

However, it cannot pick up the HttpContext. Performing this action:

Imports System.Web _ApplicationBase = HttpContext.Current() 

Tells me that the HttpContext is not declared. If you look at the methods and properties inside System.Web, it is unlikely to be shown: only AspHostingPermission, AspHostingPermissionAttribute, AspHostingPermissionLevel and Services.

The link is valid and points to the right place. It drives me crazy - what did I miss?

Cheers, Matt

+4
source share
2 answers

The HttpContext object exists only during an asp.net request in the thread that processes the request. There is no HttpContext in any other thread or process.

+4
source

If this error occurs during development, then this is the case when there is no link to the assembly. Make sure your project references the System.Web.dll assembly.

+7
source

Source: https://habr.com/ru/post/1306463/


All Articles