[RESOLVED]'System.Web.HttpContext' does not contain a definition for 'GetOwinContext'

I have the following error :’System.Web.HttpContext’ does not contain a definition for ‘GetOwinContext’ whenever I debug my project. this error is in the web API page, although it doesn’t show an error in the default AccounController.cs and the nuget package
is installed.what is missing?

using IdentitySample.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using System.Web;
using System.Threading.Tasks;
using task.Models;
using System.Globalization;
public ApplicationUserManager UserManager
            return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();

        private set
            _userManager = value;

The GetOwinContext extension method is in the  System.Web.Http.Owin dll which needs to be downloaded from nuget if not referred already.




as mentioned in the question above I already installed the nuget package and it doesn’t show an error in the AccountController.cs although the same functioni n both api and controller.only shows an error in api

            return _userManager ?? HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();


Assuming you have installed systemweb from nuget:


Leave a Reply