Reputation: 6270
I have action method in controller called "Registration" as
public ActionResult Facility(int id = 0, int contractId = 0)
when I call this method from url like
/Registration/Facility/0?contractId=0
it works fine. Now when I try to construct above url in another method like
return RedirectToAction("Facility/0?contractId="+ model.ContractId);
it doesn't work, the url in browser is not constructed well it comes like
/Registration/Facility/0%3fcontractId%3d0
can anyone please tell me what wrong I'm doing here?
Upvotes: 5
Views: 18625
Reputation: 18797
You have to pass the parameters like below:
return RedirectToAction("Facility", new { contractId = model.ContractId });
Upvotes: 0
Reputation: 8595
There is a built in method overload for redirecting. Pass in an anonymous object with the values you want
return RedirectToAction("Facility", new { id = 0, contractId = model.ContractId });
Upvotes: 1
Reputation: 18620
Try this:
return RedirectToAction("Facility", new { id = 0, contractId = model.ContractId});
See this answer
Upvotes: 11