1
다른 DLL에 IAppBuilder
을 구성하는 메서드를 만들려고합니다. 나는 Identity와 Owin을 실험하고 있으며, 나는 단지 어떻게 작동하는지 이해하려고 노력하고 있습니다.프로젝트 외부에서 IAppBuilder 구성
다음 코드는 작동 : 내가하고 싶었던 무엇
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("");
}
}
이이었다 :
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app = new AppBuilderService.BuildApp(app);
}
}
내가 BuildApp
방법에 추가 시도 코드 : 당신으로
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;
}
코드가 거의 동일하다는 것을 알 수 있습니다. 내가 겪고있는 문제는 CookieAuthenticationOptions.AuthenticationType
은 항상 빨간색이고 Visual Studio는 인식 할 수 없으며 빌드 할 수 없다는 것입니다. 내가 시작에서 가지고있는 모든 진술을 사용하여 누락 된 참조가 무엇인지 알 수없는 것 같습니다. VS도 제안을하지 않습니다.
이 작업을 수행하기위한 참조 자료는 무엇이 있습니까?
'DefaultAuthenticationTypes'가 속한 마이크로 소프트 ASP.NET 정체성과 관련된 기본 인증 유형을 열거하는 OWIN에 의해 사용되는
Assembly Microsoft.AspNet.Identity.Core.dll, v2.0.0.0
에서 발견
Microsoft.AspNet.Identity
의 일부입니다 'Microsoft.AspNet.Identity'가 어셈블리 Microsoft.AspNet.Identity.Core.dll, v2.0.0.0'에 있습니다. – Nkosi@Nkosi 제가 Owin에서 검색을 계속했는지 확인하십시오 https://msdn.microsoft.com/en-us /library/microsoft.owin.security.authenticationoptions (v = vs.113) .aspx – Bojan