我有以下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
时,它会重定向到
而不像我明确指定的Admin
区域。
为什么不起作用