如何使用参数重定向到Action [英] how to redirect to Action with parmeters

查看:76
本文介绍了如何使用参数重定向到Action的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//this is the action I want to redirect to, how can I do it   
  public ActionResult StoreOrderHistory(int? page, int storeID, int? month)
   {

   }

public ActionResult Edit(OrderInfo objOrderInfo)
{
  return RedirectoToAction();
}

推荐答案

创建一个这样的动作链接,

Create one action link like this,
@Url.Action("Edit", "ControllerName", new { page = 1})





正如你所拥有的那样重写方法,你需要属性,如HttpGet / HttpPost。

你的HttpGet方法应该返回一些View,在你的情况下它是空白的。



[评论后更新]

哦!你的意思是。这不是你的问题。

无论如何,使用返回RedirectToAction(编辑,新的{page = 1,storeID = 0})





-KR



As you've having overridden methods, you need to attribute the, as HttpGet/HttpPost.
You're HttpGet method should return some View, which in your case it is blank.

[Update after a comment]
Oh! You meant that. That wasn't in your question.
Anyway, use return RedirectToAction("Edit", new { page = 1, storeID = 0})


-KR


Hi ,

You can pass parameters in second parameters of a RedirectToAction method [ object rout values]

return RedirectToAction("Index", new { parameters });


你可以尝试

You can try
public ActionResult StoreOrderHistory(int? page, int storeID, int? month)
   {
 
   }

public ActionResult Edit(OrderInfo objOrderInfo)
{
     if (ModelState.IsValid)
     {
         return RedirectToAction("StoreOrderHistory", new {
               page = 5,
               storeID= 5432,
               month= 1
           });
     }
     return view(Model);
}


这篇关于如何使用参数重定向到Action的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆