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

时间:2016-01-11 07:08:47

标签: asp.net-core asp.net-core-mvc

我有以下HomeController

[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中执行此操作,如this answer

中所示

在我的Startup.cs底部

public void ConfigureServices(IServiceCollection services){

...

    services.Configure<CookieAuthenticationOptions>(options =>
    {
         options.LoginPath = new PathString("/Admin/Account/Login");
    });

但是,在运行我的应用程序/Home/Index时,它会重定向到

  

http://localhost:59693/Account/Login?ReturnUrl=%2F

而不像我明确指定的Admin区域。

为什么不起作用

0 个答案:

没有答案
相关问题