Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
533 views
in Technique[技术] by (71.8m points)

c# - Aspnetboilerplate: Configure login path for redirect on core mvc template

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")
        );
    });
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...