Reputation: 2282
I am checking if a user is authenticated, and need to direct to a different view if the user is not autheticated.
public ActionResult UserMaintenance()
{
if (User.Identity.IsAuthenticated)
{
return View();
}
else
{
LogOn.View; //// this is the area that needs help
}
}
I would like to present the user the view to enter the login and password....
thank you
Upvotes: 0
Views: 137
Reputation: 13150
You can use RedirectToAction
to any action in any controller.
return RedirectToAction("Action", "Controller");
As you are using ASP.net MVC you can redirect it to LogOn
action in Account
controller
public ActionResult UserMaintenance()
{
if (User.Identity.IsAuthenticated)
{
return View();
}
else
{
return RedirectToAction("LogOn", "Account");
}
}
Upvotes: 2
Reputation: 896
I would use
http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction(v=vs.98).aspx
and create a new controller method to handle the login.
Upvotes: 0