Madhavan NR
Madhavan NR

Reputation: 188

Redirect to Index Method having no parameters

Please help me, in my controller I am having 2 action methods with same name called "Index" but with different parameters ..

 public ActionResult Index()
        {...}

 [HttpPost] 

 public ActionResult Index(PickingMobile mi, string hdnSelectOperation, string btnMPSearch, string btnSearchMP)
        {...}

Now from other action I want to redirect to Index action which has no parameters

public ActionResult ConfirmBatchPicking(PickingMobile DirectPicking)
        {
...
 return RedirectToAction("Index", "ManualPickingSearch");// from here I need to redirect to first Index Method which does not have any parameters
          }

But when I keep the break point and debugging the sequence, the first Index method is not getting hit. Please help me , how to redirect to first Index action.

Upvotes: 0

Views: 936

Answers (2)

Sukesh Marla
Sukesh Marla

Reputation: 177

  1. RedirectToAction returns RedirectToRouteResult to browser in response. This response makes browser to make a new get request to another action method(in your case Index action in ManualPickingSearchcontroller)
  2. Your second Index action (one with parameter) is attached with httpPost attribute.It means only post request can be made to it.

And so, when you say return RedirectToAction("Index", "ManualPickingSearch"); it will redirect to first action method by default. Its the default behavior. Its how it should work. Please check if you are missing something.(Check the controller Name)

Upvotes: 1

Saranga
Saranga

Reputation: 3228

Try this;

return RedirectToAction("Index");

Upvotes: 0

Related Questions