I am working on a project where I have a C# class library which needs to use the System.web.HttpContext
. I've done this before in another project without problem but now its not working. I'm not sure what I am missing they're both targeting .net 3.5 and I've added the reference System.web
and added the directive using System.web
.
However, when I try and do HttpContext
nothing is found. I've tried using the full path System.web.HttpContext
but the only thing that comes up are 3 items related to ASP.
Below are screenshots from the working project intellisense and the non-working intellisense
Below is the working screenshot
and below is the non working screenshot
Thanks for any help you can provide
ASP.NET Core apps access HttpContext through the IHttpContextAccessor interface and its default implementation HttpContextAccessor. It's only necessary to use IHttpContextAccessor when you need access to the HttpContext inside a service.
The HttpContext encapsulates all the HTTP-specific information about a single HTTP request. When an HTTP request arrives at the server, the server processes the request and builds an HttpContext object. This object represents the request which your application code can use to create the response.
HttpContext is a type which has a static Current property that you're using to get the current context. There isn't a System. Web. Mvc.
This means that either you are using a Client Profile as the Target Framework or the reference to System.Web was not added correctly.
Despite your comment that you've added reference to System.Web to the project it is still most likely reason of what you are seeing.
The classes you see are coming from System.Dll, not System.Web.Dll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With