When a user logs in i want them to see only db entry that match there id on the index page
im currently using the below which works as fare as getting the correct data but get a error when i run the project
Code:
public ActionResult Index()
{
return View(db.UserProfiles.ToList().Where(u => u.UserId ==
(int)Membership.GetUser().ProviderUserKey));
}
Error: nullreferenceexception was unhandled by the user code Object reference not set to an instance of an object.
To fully implement authorization in MVC4 you have to do a little more work then that. I found (and used) a great article for this problem : http://primaryobjects.com/CMS/Article147.aspx[^]
Also you try put [Authorize] above the index call method.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加