views:

15

answers:

0

I've the following scenario:

  1. Go to the /User.mvc?userId=200&otherId=1 page.
  2. Change some data.
  3. Press Update button.
  4. Show the /User.mvc?userId=200&otherId=1 page.

I used MvcContrib + T4MVC with the following code:

[AllRolesAuthorize()]
public virtual ViewResult Index(long? userId, long? subPracticeId)
{
    long selectedUserId = userId ?? GetUserId();

    var listModel = // My model

    // Only show UpdateButton if userId == CurrentUser
    listModel.ShowUpdateButton = selectedUserId == GetUserId();

    return View(Views.Index, listModel);
}

// POST: /Update/
[HttpPost]
[AllRolesAuthorize()]
public virtual ActionResult Update(ListSkillLevelModel model)
{
    // Update

    // Redirect to /User.mvc?userId=xxx&otherId=yyy
    // Note : for some reason I can't use return Index(GetUserId(), model.OtherId)

    var rv = new RouteValueDictionary();
    rv.Add("Action", "Index");
    rv.Add("userId", GetUserId());
    rv.Add("otherId", model.OtherId);

    return RedirectToRoute("Default", rv);
}

When I use return Index(GetUserId(), model.OtherId) I end up at the User.mvc/Update page, this is not correct, I want to end up at the user.mvc/Index page.