我使用授權屬性來檢查用戶是否被授權或不要進入特殊視圖。使用授權屬性ASP.Net MVC
[HttpGet]
[Authorize]
public ActionResult Index(int ID)
{
ViewBag.sID = ID;
return View();
}
假設這是畝URL:本地主機:16621 /面板/索引/ 1 現在,這個授權用戶可以更改爲1〜2,然後導航到另一個用戶的信息。像本地主機:16621 /面板/索引/ 2 如何防止這種?有沒有辦法將參數傳遞給授權屬性? 如何防止用戶訪問其他用戶信息?
安吉麗娜。這已經是很多時間了。 http://stackoverflow.com/questions/2329197/custom-form-authentication-authorization-scheme-in-asp-net-mvc?rq=1 http://stackoverflow.com/questions/427598/customizing-authorization- in-asp-net-mvc?rq = 1 http://stackoverflow.com/questions/554094/asp-net-mvc-adding-to-the-authorize-attribute?rq=1 –
看看這篇文章,它正是你想要的。 http://stackoverflow.com/questions/10064631/mvc-3-access-for-specific-user-only – SOfanatic