ASP.NET Core 2.1 Identity: How to remove the Default UI razor pages?

Using the article linked by Panagiotis Kanavos, I was able to reach a solution. From the ASP.NET Core 2.1.0-preview1, there was a line .AddDefaultUI(), which you didn’t have to include in Startup.cs. services.AddIdentity<IdentityUser, IdentityRole>(options => options.Stores.MaxLengthForKeys = 128) .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultUI() .AddDefaultTokenProviders(); In the final release version of Core 2.1 however, the same section was simplified … Read more

Removing Kestrel binding warning

This is an old question but you can resolve that conflict between launchSettings.json and appSettings.json with “externalUrlConfiguration”: true Kestrel configuration in appSettings.json: “Kestrel”: { “EndpointDefaults”: { “Protocols”: “Http1AndHttp2” }, “Endpoints”: { “HTTPS”: { “Url”: “https://localhost:4433” } } And this is launchSettings.json content: { “profiles”: { “TestApplication”: { “commandName”: “Project”, “launchBrowser”: true, “externalUrlConfiguration”: true, //add this … Read more

Has something replaced bundleconfig.json in ASP.NET Core MVC 2.1?

bundleconfig.json was removed from the 2.1 templates because it relied on a tool not created or supported by Microsoft. See https://github.com/aspnet/templating/issues/326. This file [bundleconfig.json] is for configuring the various incantations of the BundlerMinifier tool, which isn’t actually shipped in the templates, or supported by Microsoft. The ASP.NET Core team has replaced bundleconfig with “libman”. Rightclick … Read more

Access DbContext service from background task

In that case you can only rely on the servicelocater-pattern which is an anti-pattern. Also the DbContext must be instance-per-dependency (transient) rather than scoped. My suggestion is to inject IServiceScopeFactory which is a singleton and the beginn a scope in your background-worker that does the deed. using (var scope = _serviceScopeFactory.CreateScope()) { var context = … Read more

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

I’ll answer your question directly then propose an alternative. You can Remove, Set, Get, and Validate tokens with the AspNetUserTokens table. However, you can probably skip the db and I’ll describe that below. The following methods of the UserManager will generate and store: await _userManager.RemoveAuthenticationTokenAsync(user, “MyApp”, “RefreshToken”); var newRefreshToken = await _userManager.GenerateUserTokenAsync(user, “MyApp”, “RefreshToken”); await … Read more

Is .NET Core Runtime backwards compatible with previous releases?

Edit .NET Core 3.x SDK has been released. Unlike v2.2 and the previous releases before it, this version does not support the ability to target previous runtimes (i.e. netcoreapp2.2, netcoreapp2.1, etc) tldr; Yes. By installing .NET Core Runtime 2.2.3, you can run apps which target netcoreapp2.0, netcoreapp2.1, and netcoreapp2.2, without requiring additional runtimes to be … Read more

Core 2.1 refuses to respond with Access-Control-Expose-Headers: *

The CorsPolicyBuilder‘s AllowAnyHeader method configures the Access-Control-Allow-Headers response header, which is used only for preflighted requests. The Access-Control-Expose-Headers response header is what’s needed, which is configured using WithExposedHeaders. Here’s a complete example: services.AddCors(options => { options.AddPolicy(“AllowAll”, builder => { builder.AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin() .AllowCredentials() .WithExposedHeaders(“Location”); // params string[] }); });