首页 > 解决方案 > “IAppBuilder”不包含“UseCookieAuthentication”的定义

问题描述

“IAppBuilder”不包含“UseCookieAuthentication”的定义,并且最佳扩展方法重载“CookieAuthenticationExtensions.UseCookieAuthentication(IAppBuilder, CookieAuthenticationOptions)”需要“IAppBuilder”类型的接收器

public void ConfigureAuth(IAppBuilder app)
    {
      app.CreatePerOwinContext(ApplicationDbContext.Create);
      app.CreatePerOwinContext<ApplicationUserManager> 
                      (ApplicationUserManager.Create);

      app.UseCookieAuthentication(new CookieAuthenticationOptions());
   app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

        PublicClientId = "self";
        OAuthOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/Token"),
            Provider = new ApplicationOAuthProvider(PublicClientId),
            AuthorizeEndpointPath = new 
                           PathString("/api/Account/ExternalLogin"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(14)            
        };

            app.UseOAuthBearerTokens(OAuthOptions);
      }

标签: c#

解决方案


您将需要添加对 的程序集引用Microsoft.Owin.Security.Cookies,您可以从 Nuget 下载它。然后确保也添加使用:

using Microsoft.Owin.Security.Cookies;

推荐阅读