HttpContext does not exist in System.Web

I created a new project with the template "Console App (.NET Core)". So when I try manually referencing System.Web through "Add reference", there will be no reference tab.

Can anyone help how to add reference of HttpContext?

enter image description here

1 answer

  • answered 2022-01-25 13:46 Sherif Elmetainy

    The System.Web based HttpContext is a class in .NET Framework (versions 1-4) and not available in either .NET Core (Version 1-3) or .NET (version 5 or 6).

    In a console application the current HttpContext will always be null. If you are creating a .NET Core web application, you can read the documentation in the following link to access current HttpContext.

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-6.0

    May be if you provide more details about what you are trying to achieve by using HttpContext in a console application, you will get a better answer.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum