I can't get RedirectToAction to work
Posted
by DaveDev
on Stack Overflow
See other posts from Stack Overflow
or by DaveDev
Published on 2010-05-14T10:31:07Z
Indexed on
2010/05/14
10:34 UTC
Read the original article
Hit count: 253
c#
|asp.net-mvc
I have the following Action Method that I'm trying to redirect from if the user is valid. But nothing happens. The breakpoint in the redirected-to action method never gets hit.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Login(User user)
{
try
{
if (ModelState.IsValid)
{
if (userRepository.ValidUser(user))
{
return RedirectToAction("Index", "Group");
}
else
{
return Json("Invalid");
}
}
}
catch (Exception)
{
return Json("Invalid");
}
}
And in another Controller, I have the following Action Method that I'm trying to redirect to:
// HttpVerbs.Post doesn't work either
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index(int? page)
{
const int pageSize = 10;
IEnumerable<Group> groups = GetGroups();
var paginatedGroups = new PaginatedList<Group>(groups, page ?? 0, pageSize);
return View(paginatedGroups);
}
private IEnumerable<Group> GetGroups()
{
return groupRepository.GetGroups();
}
Is there anything obviously wrong with what I'm doing? Could somebody suggest a different approach I could take?
© Stack Overflow or respective owner