Startup.cs

public void ConfigureServices(IServiceCollection services)
{
	// register services to make available to app (DI, to use in Configure() etc.)
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	// hook into pipeline, configures if needed
}

MVC controllers

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...
	
	services.AddControllersWithViews()
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	
	app.UseRouting();
	app.UseCors();

	app.UseAuthentication();
	app.UseAuthorization();

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

Identity settings

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...
	
	services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
	services.AddDefaultIdentity<IdentityUser>();
	services.AddEntityFrameworkStores<ApplicationDbContext>();
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	
	app.UseAuthentication();
	
	// ... ... ...
}

Authorization

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...
	
	services.AddAuthorization(o => o.AddPolicy(_RequireAuthenticatedUserPolicy, builder => builder.RequireAuthenticatedUser()));

	// or
	services.AddAuthorization(options =>
	{
		options.DefaultPolicy = new AuthorizationPolicyBuilder()
		  .RequireAuthenticatedUser()
		  .Build();
	});
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	
	app.UseAuthentication();
	app.UseAuthorization();

	app.UseEndpoints(endpoints =>
	{
		endpoints.MapDefaultControllerRoute().RequireAuthorization(_RequireAuthenticatedUserPolicy);
		endpoints.MapRazorPages();
	});

	// or
	app.UseEndpoints(endpoints =>
	{
		endpoints.MapDefaultControllerRoute().RequireAuthorization();
		endpoints.MapRazorPages();
	});
	
	// ... ... ...
}

Password settings

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...

	services.Configure<IdentityOptions>(options =>
	{
		// Password settings.
		options.Password.RequireDigit = true;
		options.Password.RequireLowercase = true;
		options.Password.RequireNonAlphanumeric = true;
		options.Password.RequireUppercase = true;
		options.Password.RequiredLength = 6;
		options.Password.RequiredUniqueChars = 1;
	}
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	

	
	// ... ... ...
}

Lockout settings

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...

	services.Configure<IdentityOptions>(options =>
	{
		// Lockout settings.
		options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
		options.Lockout.MaxFailedAccessAttempts = 5;
		options.Lockout.AllowedForNewUsers = true;
	}
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	

	
	// ... ... ...
}

User settings

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...

	services.Configure<IdentityOptions>(options =>
	{
		// User settings.
		options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
		options.User.RequireUniqueEmail = false;
	}
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	

	
	// ... ... ...
}
public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...

	services.Configure<CookiePolicyOptions>(options =>
	{
		options.CheckConsentNeeded = context => true;
		options.MinimumSameSitePolicy = SameSiteMode.None;
	});


	services.ConfigureApplicationCookie(options =>
	{
		// Cookie settings
		options.Cookie.HttpOnly = true;
		options.ExpireTimeSpan = TimeSpan.FromMinutes(5);

		options.LoginPath = "/Identity/Account/Login";
		options.AccessDeniedPath = "/Identity/Account/AccessDenied";
		options.SlidingExpiration = true;
	});
	
	// ... ... ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

	// ... ... ...
	
	app.UseCookiePolicy();
	
	// ... ... ...
}

Cache settings

public void ConfigureServices(IServiceCollection services)
{
	// ... ... ...

	var connectionString = @"...";
	services.AddDistributedSqlServerCache(opt =>
	{
		opt.ConnectionString = connectionString;
		opt.SchemaName = "dbo";
		opt.TableName = "SQLCache";
	});
	
	// ... ... ...
}

See:

SignalR

// ... ... ...

using SignalRChat.Hubs;

namespace SignalRChat
{
    public class Startup
    {
	
        public IConfiguration Configuration { get; }
		
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddSignalR();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {

            // ... ... ...

            app.UseRouting();

            // ... ... ...

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapHub<ChatHub>("/chatHub");
            });
        }
    }
}