Aspnetboilerplate:在核心 mvc 模板上配置用于重定向的登录路径

Aspnetboilerplate: Configure login path for redirect on core mvc template

抱歉,如果这很简单,但我真的遇到了这个问题。

我正在尝试将所有标准视图和控制器从 aspnetboilerplate 的模块零(核心 + MVC + jQuery)移动到一个新区域(管理员),并希望确保重定向以在未经授权的情况下登录视图转到 /Admin/Login 而不是 /Account/Login,这是默认值。

非常感谢任何帮助。

戴尔

更新

这里是 ConfigureServices 方法:

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    //MVC
    services.AddMvc(options =>
    {
        options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
    });

    IdentityRegistrar.Register(services);
    AuthConfigurer.Configure(services, _appConfiguration);

    services.ConfigureApplicationCookie(options => options.LoginPath = "/Admin/Login");

    services.AddScoped<IWebResourceManager, WebResourceManager>();

    //Configure Abp and Dependency Injection
    return services.AddAbp<CrowdsiteWebMvcModule>(options =>
    {
        //Configure Log4Net logging
        options.IocManager.IocContainer.AddFacility<LoggingFacility>(
            f => f.UseAbpLog4Net().WithConfig("log4net.config")
        );
    });
}

您可以在 Startup.cs 中进行配置:

IdentityRegistrar.Register(services);
AuthConfigurer.Configure(services, _appConfiguration);

// Add this line:
services.ConfigureApplicationCookie(options => options.LoginPath = "/Admin/Login");

相关文档:https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x