c# - 在 ASP.net core 3.0 中更改身份登录 URL

标签 c# asp.net-mvc asp.net-core asp.net-core-3.0

我正在尝试从以下位置更改默认登录 URL:

 /Identity/Account/Login


/Login

我查过类似的问题,他们想出了一个类似的解决方案:
public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<CompanyLoginContext>(options =>
        options.UseNpgsql(
            Configuration.GetConnectionString("DefaultConnection")));

    services.AddIdentity<CompanyLoginUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
       .AddEntityFrameworkStores<CompanyLoginContext>()
       .AddDefaultTokenProviders();

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

        options.LoginPath = new PathString("/Login");
        options.AccessDeniedPath = new PathString("/Logout");
        options.AccessDeniedPath = new PathString("/AccessDenied");

        options.SlidingExpiration = true;
    }); 
}

但不知何故,这是行不通的。

最佳答案

确保你有脚手架的身份,你可以引用here .

然后需要修改Identity/Account/Login.cshtml像下面这样:

@page "/Login"

关于c# - 在 ASP.net core 3.0 中更改身份登录 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525775/

相关文章:

dependency-injection - 是否可以通过约定在.NET Core中注册依赖项?

c# - 使用 IComparable

c# - 为 WP8 平台构建原生 OpenSSL 库

c# - 在 ASP.NET MVC 中关闭浏览器或选项卡时如何注销用户?

asp.net-mvc - 将 ssl 与 aspnet mvc 一起使用会在将数据发布到安全页面时产生问题

asp.net-mvc - 找不到键为 '<key>' 的资源对象。自动部署的 ASP.NET MVC3 应用程序

c# - 什么是 ObjectFactory.Inject 在 StructureMap 3.0 中的等价物

javascript - 无法在 MVC 5 应用程序的 api Web API 2 Controller 中访问 Action

c# - 将 Prebuild 或 Postbuild 添加到 dotnet 核心项目

Elasticsearch 和 Asp.Net Core