Why I am getting, The path in 'value' must start with '/'. (Parameter 'value')
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/Login";
});
ArgumentException: The path in 'value' must start with '/'. (Parameter 'value')
Why I am getting, The path in 'value' must start with '/'. (Parameter 'value')
In my test, I can reproduce the issue once I ommit the "/" from the login path. As you can see the error I reproduce:
I have tried in following way:
Login Convention I set:
builder.Services.AddMvc().AddRazorPagesOptions(options =>
{
options.Conventions.AllowAnonymousToPage("/Login");
});
Cookie Authentication Configuration:
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/Login";
});
Middleware I am using:
app.UseDeveloperExceptionPage();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.UseAuthentication();
Output: