问题描述
所以,我更新了MongoDB的一个开源asp.net身份提供商,Asp.Net 3.0身份(又名vnext)工作。到目前为止,我已经能够注册提供商,创建用户,但使用时SignInManager如果一个正确的用户名,提供/通过我的错误
I have tracked down the error to herehttps://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs
but I can't seem to see where the SignInContext.Accepted name is getting added to the SignInContext.
I am using the Alpha-2 versions of all of the vnext libraries that are being used in VS14 CTP2
Below is my 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;
}
}
Turns out I had setup MVC before the CookieAuthentication so the AuthenticationType was not registered in MVC when it tried to authenticate the user. As MVC depends upon the authentication I just had to bump it up and register it before MVC.
这篇关于如何注册在asp.net vnext认证类型名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!