Aspnetboilerplate: Configure login path for redirect on core mvc template

不打扰是莪最后的温柔 提交于 2019-12-24 19:12:43

问题


Sorry if this is straightforward, but I'm having a real block with this one.

I'm trying to move all the standard views and controllers from aspnetboilerplate's Module Zero (Core + MVC + jQuery) into a new area (Admin) and want to make sure the redirect for login on unauthorized view goes to /Admin/Login as opposed to /Account/Login, which is the default.

Any help really appreciated.

Dale

Update

Here is the ConfigureServices method:

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")
        );
    });
}

回答1:


You can configure that in Startup.cs:

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

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

Related docs: https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x



来源:https://stackoverflow.com/questions/47437295/aspnetboilerplate-configure-login-path-for-redirect-on-core-mvc-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!