I am working on couple of projects one of which is an ASP.NET 4.5
application and other one is .Net Core API 1.1
project. The asp.net application is using HttpContext
classes to read cookies and page headers. Now, I need to move this to a .net standard library which can be used by both the project. I don't find HttpContext in .net standard SDK. Any suggestions?
There's a problem to your approach: .NET Standard is the most bare-bones implementation of .NET available, meaning that only basic features which are platform- and scenario-agnostic are implemented.
HttpContext
exists on both the .NET Framework and .NET Core (both of which implement .NET Standard, by the way), but being specific to the Web, it does not exist on .NET Standard.
So, you have three options:
System.Web.HttpContext
Microsoft.AspNetCore.Http.HttpContext
HttpContext
away from the .NET Standard projectDo notice, though, that those classes vary greatly. The .NET Core version was created for ASP.NET Core which is vastly different to ASP.NET 4.5 and olders.