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はまた何の示唆もしていない。
私はこの資料を見逃していますか?
'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@Nkosi Owinで検索しています。https://msdn.microsoft.com/en-us /library/microsoft.owin.security.authenticationoptions (v = 117).aspx – Bojan