I have authentification using Identity. But if I use [Authorize] atribute, I`m redirected to localhost:7174/Identity/Account/Login?ReturnUrl=%2FUser%2FUser while I don't have such page. How to change this url? I didn't find any methods or properties that can change that. Also, I added that Identity pages with Scaffold. But even now it said that it's impossible to reach such page. What should I better do?
I don't know what could be usefull for you, so here is my program.cs
using DreamWeb.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMvc();
builder.Services.AddControllersWithViews();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddDbContext<DreamsContext>(options =>
options.UseSqlServer("server = SCAT\\SQLEXPRESS; database = dreams_web; Trusted_Connection=True ; MultipleActiveResultSets = true"));
builder.Services.AddDefaultIdentity<UserAccount>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<DreamsContext>();
builder.Services.AddAuthentication().AddCookie();
builder.Services.Configure<IdentityOptions>(options =>
{
options.SignIn.RequireConfirmedPhoneNumber = false;
options.SignIn.RequireConfirmedEmail = false;
options.SignIn.RequireConfirmedAccount = false;
options.Password.RequireUppercase = false;
options.Password.RequireDigit = false;
options.Password.RequiredLength = 1;
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
});
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
MapControllerRoutewith additional entries. You can useMapControllersif you like to move from the table to attribute based routing.