【问题标题】:how to add additional arguments to RedirectPermanent?如何向 RedirectPermanent 添加其他参数?
【发布时间】:2013-09-13 19:26:09
【问题描述】:

我想在我的返回操作中添加一个 viewbag 消息,类似这样......

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

以上工作正常,但是我试图在选项卡式索引视图上做同样的事情,我发现在发布操作后导航回所需选项卡的唯一方法如下......

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

基本上索引是视图,用户是索引页面上的选项卡式视图... 有没有办法让 RedirectPermanaent 接受第二个参数? 谢谢..

【问题讨论】:

    标签: c# html asp.net-mvc-4


    【解决方案1】:

    如果你必须使用RedirectPermanent没有第二个参数,你可以使用String.Format来制作url

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

    但您可以使用RedirectToActionPermanent 来解决您的问题

    【讨论】:

      猜你喜欢
      • 2020-08-03
      • 2012-12-21
      • 1970-01-01
      • 2013-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多