سلام خسته نباشید. توی startup من اومدم مسیر LoginPath رو اون چیزی که میخوام گذاشتم ولی برنامه باز میبره کاربرو به صفحه /Identity/Account/Login
نمیدونم مشکل چیه دقیقا
حالا جالب تر اینه که من اون razor page رو از پروژه پاک کردم ولی باز داره اون صفحه رو نشون میده و عجیبه این مورد !!
محتوای کلاس Startup را قرار بدید.
services.ConfigureApplicationCookie(options =>
{
options.AccessDeniedPath = "/Identity/Account/AccessDenied";
options.Cookie.Name = StaticDetails.UserCookieName;
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
options.LoginPath = new PathString("/Account/Login");
options.LogoutPath = "/Identity/Account/Logout";
// ReturnUrlParameter requires
//using Microsoft.AspNetCore.Authentication.Cookies;
options.ReturnUrlParameter = "returnUrl";
options.SlidingExpiration = true;
});
این اون قسمت مورد نظر که loginPath که من مشخص کردمو اصلا قبول نمیکنه و میره حالت پیش فرض خودشو انتخاب میکنه ینی/Identity/Account/Login
using System;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Rewrite.Internal;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SpoonAndFork.Data;
using SpoonAndFork.Data.Context;
using SpoonAndFork.Domain.Models;
using SpoonAndFork.Services.Services;
using SpoonAndFork.Services.Services.MainPage;
using SpoonAndFork.Utility;
using SpoonAndFork.Web.Helper.EmailHelper;
using SpoonAndFork.Web.IdentityManagers;
namespace SpoonAndFork.Web
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddErrorDescriber<PersianIdentityErrorDescriber>()
.AddClaimsPrincipalFactory<AppUserClaimsPrincipalFactory>()
.AddDefaultTokenProviders();
services.ConfigureApplicationCookie(options =>
{
options.AccessDeniedPath = "/Identity/Account/AccessDenied";
options.Cookie.Name = StaticDetails.UserCookieName;
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
options.LoginPath = new PathString("/Account/Login");
options.LogoutPath = "/Identity/Account/Logout";
// ReturnUrlParameter requires
//using Microsoft.AspNetCore.Authentication.Cookies;
options.ReturnUrlParameter = "returnUrl";
options.SlidingExpiration = true;
});
services.Configure<IdentityOptions>(options =>
{
// Default Lockout settings.
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.AllowedForNewUsers = true;
// Default Password settings.
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequiredLength = 6;
options.Password.RequiredUniqueChars = 1;
// Default SignIn settings.
options.SignIn.RequireConfirmedEmail = false;
options.SignIn.RequireConfirmedPhoneNumber = false;
// Default User settings.
options.User.AllowedUserNameCharacters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
options.User.RequireUniqueEmail = true;
});
services.AddScoped<IDbInitializer, DbInitializer>();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
});
services.AddTransient<IProductCategoryService, ProductCategoryService>();
services.AddTransient<IWebSiteStatisticsService, WebSiteStatisticsService>();
services.AddTransient<IOrderAndCommentsStatisticsService, OrderAndCommentsStatisticsService>();
services.AddTransient<IBlogService, BlogService>();
services.AddTransient<IAttributesService, AttributesService>();
services.AddTransient<IShopSettingService, ShopSettingService>();
services.AddTransient<IProductService, ProductService>();
services.AddTransient<IOrderService, OrderService>();
services.AddTransient<IBlogCommentService, BlogCommentService>();
services.AddTransient<IProductCommentsService, ProductCommentsService>();
services.AddTransient<IPaymentAdminService, PaymentAdminService>();
services.AddTransient<IMainPageCategoriesService, MainPageCategoriesService>();
services.AddTransient<IMainPageBlogService, MainPageBlogService>();
services.AddTransient<IFixedUrl, FixedUrl>();
services.AddScoped<IEmailSender, EmailSender>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env
, IDbInitializer dbInitializer)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
dbInitializer.Initialize();
app.UseAuthentication();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areas",
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}"
);
});
}
}
}