mkell
mkell

Reputation: 731

how to add additional arguments to RedirectPermanent?

I want to add a viewbag message to my return Action something like this....

return RedirectToAction("Index", new { Message = "Accepted Successfully" });

The above works fine, however I am trying to do the same on a tabbed Index view, which I discovered the only way to navigate back to the desired tab after post action is the following...

return RedirectPermanent("~/ReferralTarget/Index/#users");

Basically Index is the view and user is a tabbed view on the Index page... Is there a way by which RedirectPermanaent will take a second argument ? Thanks..

Upvotes: 1

Views: 472

Answers (1)

Milad Hosseinpanahi
Milad Hosseinpanahi

Reputation: 1495

if you must use RedirectPermanent there is no second argument, you can use String.Format to make the url

return RedirectPermanent(
 String.Format("~/ReferralTarget/Index/#users?Message={0}", "Message here"));

but you can use RedirectToActionPermanent to solve your problem

Upvotes: 1

Related Questions