c# – Reference to type ‘HttpContextBase’ claims it is defined in ‘System.Web’ but it could not be found

0
18

I’m getting a really weird error that I’ve only found a few times with some pretty extensive googling. I’m making an authorization attribute to add onto my Actions in an ASP.NET MVC project in a class library. I installed the ASP packages through NuGet and can use intellisense to get the HttpContext from the filterContext, but it’s saying that the HttpContext type can’t be found where it’s supposed to be.

Reference to type ‘HttpContextBase’ claims it is defined in ‘System.Web’ but it could not be found.

There’s a few versions of this on StackOverflow, but none of them worked for me, as most of them consisted of restarting Visual Studio or just building the project.

EDIT

public class RequireLogin : IAuthorizationFilter
{
    public void OnAuthorization(AuthorizationContext filterContext)
    {
        if (filterContext.HttpContext.Request.Cookies)
        {

        }
    }
}

The error is on HttpContext on the if statement.

LEAVE A REPLY

Please enter your comment!
Please enter your name here