Answers for ".net core web api return cors error instead of 401"

C#
0

.net core web api return cors error instead of 401

public void Configure(
        IApplicationBuilder app,
        IWebHostEnvironment env,
        ApplicationDbContext dbContext,
        UserManager<ApplicationUser> userManager,
        RoleManager<UserRole> roleManager,
        AppConfigs appConfigs
    )
    {  
        if (env.IsDevelopment())
        {
            app.UseExceptionHandler("/error-local-development");
        }
        else
        {
            app.UseExceptionHandler("/error");
        } 

        app.UseRouting();

        app.UseCors(MyAllowSpecificOrigins);
         
        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });

        app.UseStaticFiles();

        // ===== Create tables ====== 
        DataInitializer.SeedData(dbContext, userManager, roleManager, appConfigs);

    }
Posted by: Guest on May-10-2021

Code answers related to ".net core web api return cors error instead of 401"

C# Answers by Framework

Browse Popular Code Answers by Language