Reputation: 181
I am new to asp.net Identity and I cannot seem to figure out how to only allow logged in users to access certain pages in my controllers. All the documentation I am reading seems dated. Basically I would like to forward the user to a login page when they make a request to the server which runs one of the specified controller functions like so
//How do I prevent anonymous user from preforming this model action
//Unless they are logged in
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SomeModelAction([Bind("ID,AModelField,UserID")] AModel aModel)
{
//code to preform action on a model
return View(aModel);
}
Upvotes: 1
Views: 838