所以我有一个关于
[Authorize]
标签我需要用户具有管理员角色才能访问某个视图。它工作得很好,只允许“管理员”而不是“用户”访问它。但每当用户访问时,它都会告诉我:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Login.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009
所以我的问题是,当用户访问时,我如何将他们重定向到另一个视图?
这是我的索引控制器:
[Authorize(Users = "Admin")]
public ActionResult Index()
{
var user = db.User.Include(u => u.UserRole);
return View(user.ToList());
}