开发者

I can't get RedirectToAction to work

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 hav开发者_StackOverflow社区e 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?


Try setting the routeValues parameter with this overload:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜