开发者

passing multiple parameters in url in MVC 3

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?


Try this:

return RedirectToAction("Facility", new { id = 0, contractId = model.ContractId});

See this answer


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 });


You have to pass the parameters like below:

return RedirectToAction("Facility", new { contractId = model.ContractId });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜