因此,我正在更新 MongoDB 的开源 asp.net 身份提供程序,以使用 Asp.Net Identity 3.0(又名 vnext)。到目前为止,我已经能够注册提供程序并创建用户,但是在使用 SignInManager 时,如果提供了正确的用户名/密码,我会收到错误消息
InvalidOperationException:不接受以下身份验证类型:Microsoft.AspNet.Identity.Application
我已经将错误追踪到这里 https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs
但我似乎看不到将 SignInContext.Accepted 名称添加到 SignInContext 的位置。
我正在使用 VS14 CTP2 中使用的所有 vnext 库的 Alpha-2 版本
下面是我的 Startup.cs
public void Configure(IBuilder app)
{
try {
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
var configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
// app.UseLogRequests("try");
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseServices(services =>
{
services.AddIdentity<MyUser>()
.AddMongoDB<MyUser>(configuration.Get("Data:MongoIdentity:ConnectionString"), configuration.Get("Data:MongoIdentity:DBName"))
.AddHttpSignIn<MyUser>();
// Add MVC services to the services container
services.AddMvc();
});
// Add static files to the request pipeline
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}",
defaults: new { action = "Index" });
});
// Add cookie-based authentication to the request pipeline
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
});
}
catch (Exception ex)
{
Console.Write(ex.ToString());
throw;
}
}