简体   繁体   中英

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..

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM