ASPNETCORE 2.0 Identity – Redirect URL signin-* Returns 404

When creating an ASP.NET Core web application using the web app template in VS 2017 preview, a web application with ASP.NET Core 1.1 is scaffolded. Adding external authentication providers following this or this instruction works like a charm. But then, after migrating to ASP.NET Core 2.0, the redirect URL getting the user from the external auth provider back to the web app (i.e. /signin-microsoft, /signin-google, /signin-facebook etc.) stopped working and resulted in a 404.

In ASP.NET Core 1.1, we had to add Identity with the following statement:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseIdentity();
}

Which has changed in ASP.NET Core 2.0 to:

public void ConfigureServices(IServiceCollection services)
{
    services.AddIdentity<ApplicationUser, IdentityRole>();
}

Well, it turns out (and is stated in the documents), you now have to explicitly call “UseAuthentication”:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseAuthentication();
}

And voila, the redirect URLs work again.

 

Freelance full-stack .NET and JS developer and architect. Located near Cologne, Germany.

2 thoughts on “ASPNETCORE 2.0 Identity – Redirect URL signin-* Returns 404

Leave a Reply

Your email address will not be published. Required fields are marked *