2016-08-05 11 views
1

IAppBuilderを別のdllに設定する方法を作成しようとしています。私はアイデンティティとオーリンを試しています。私は物事の仕組みを理解しようとしています。IAppBuilderをプロジェクト外に設定する

次のコードは動作します:あなたのよう

public class AppBuilderService 
{ 
    public IAppBuilder BuildApp(IAppBuilder app) 
    { 
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
      LoginPath = new PathString("/Login"), 
      Provider = new CookieAuthenticationProvider 
      { 
       OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserService, User>(
        TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager)) 
      } 
     });    
     app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 
     app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); 
     app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); 

     app.UseTwitterAuthentication(
      consumerKey: "", 
      consumerSecret: "" 
      ); 

     app.UseFacebookAuthentication(
      appId: "", 
      appSecret: "" 
     ); 

     app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 
     { 
      ClientId = "", 
      ClientSecret = "" 
     }); 

     app.UseSteamAuthentication(""); 
    } 

    return app; 
} 

:私はBuildAppメソッドに追加しようとした

public partial class Startup 
{ 
    public void ConfigureAuth(IAppBuilder app) 
    { 
     app = new AppBuilderService.BuildApp(app); 
    } 
} 

コード:私はやりたいこと

public partial class Startup 
{ 
    public void ConfigureAuth(IAppBuilder app) 
    { 
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
      LoginPath = new PathString("/Login"), 
      Provider = new CookieAuthenticationProvider 
      { 
       OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserService, User>(
        TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager)) 
      } 
     });    
     app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 
     app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); 
     app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); 

     app.UseTwitterAuthentication(
      consumerKey: "", 
      consumerSecret: "" 
      ); 

     app.UseFacebookAuthentication(
      appId: "", 
      appSecret: "" 
     ); 

     app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 
     { 
      ClientId = "", 
      ClientSecret = "" 
     }); 

     app.UseSteamAuthentication(""); 
    } 
} 

このましたコードがほぼ同一であることが分かります。私が抱えている問題は、CookieAuthenticationOptions.AuthenticationTypeは常に赤で、ビジュアルスタジオは認識できないのでビルドできないということです。私はStartupで持っているステートメントを使って同じことをしているので、何が欠けているのか分からないようです。 VSはまた何の示唆もしていない。

私はこの資料を見逃していますか?

+0

'DefaultAuthenticationTypes'はの一部であるマイクロソフトASP.NETアイデンティティに関連付けられたデフォルトの認証タイプを列挙するためにOWINで使用されAssembly Microsoft.AspNet.Identity.Core.dll, v2.0.0.0

で見つかったMicrosoft.AspNet.Identityの一部です。 'Microsoft.AspNet.Identity'が' Assembly Microsoft.AspNet.Identity.Core.dll、v2.0.0.0'にあります。 – Nkosi

+0

@Nkosi Owinで検索しています。https://msdn.microsoft.com/en-us /library/microsoft.owin.security.authenticationoptions (v = 117).aspx – Bojan

答えて

関連する問題