Asp.net core ASP.NET 5 MVC6中未覆盖默认登录位置

Asp.net core ASP.NET 5 MVC6中未覆盖默认登录位置,asp.net-core,asp.net-core-mvc,Asp.net Core,Asp.net Core Mvc,我有以下的家庭控制器 [Area("Admin")] [Authorize(Roles = "Admin")] public class HomeController : Controller { public IActionResult Index() { return View(); } 我已经将帐户部分移动到它自己的名为Admin的区域 在ASP.NET 4中,要更改默认登录位置,可以更改web.config 但是在ASP.NET 5中,我知道您必

我有以下的家庭控制器

[Area("Admin")]
[Authorize(Roles = "Admin")]
public class HomeController : Controller
{
    public IActionResult Index()
    {
        return View();
    }
我已经将帐户部分移动到它自己的名为Admin的区域

在ASP.NET 4中,要更改默认登录位置,可以更改web.config

但是在ASP.NET 5中,我知道您必须在Startup.cs中执行此操作,如回答中所示

在我的Startup.cs的底部

public void ConfigureServices(IServiceCollection services){

...

    services.Configure<CookieAuthenticationOptions>(options =>
    {
         options.LoginPath = new PathString("/Admin/Account/Login");
    });
public void配置服务(IServiceCollection服务){
...
配置(选项=>
{
options.LoginPath=新路径字符串(“/Admin/Account/Login”);
});
但是,当运行我的应用程序
/Home/Index
时,它会重定向到

不像我明确指定的
Admin
区域


为什么不工作

您是否配置了(IApplicationBuilder应用程序)在你的启动中?里面是什么?这里是官方的cookie示例:是的,我有这个部分,它与Visual Studio 2015 Update 1 ASP.NET 5新模板中的ASP.5 RC1模板相同显示你的
Web.Config
你能显式地尝试设置options.AutomaticChallenge=true吗?你有配置(IApplicationBuilder应用程序)在你的启动中?里面是什么?这里是官方的cookie示例:是的,我有那个部分,它与Visual Studio 2015 Update 1 ASP.NET 5新模板中的ASP.5 RC1模板相同显示你的
Web.Config
你能尝试显式设置options.AutomaticChallenge=true吗?