I cannot get RedirectToAction to work

I have the following action method which I am trying to redirect if the user is valid. But nothing happens. A breakpoint in a redirected action method never hits.

[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 am 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 something clearly wrong with what I am doing? Can anyone suggest a different approach that I could take?

+2


a source to share


1 answer


Try setting routeValues

this overload option :



return RedirectToAction("Index", "Group", new { page = (int?)null });

      

+5


a source







All Articles