我在我的應用程序中使用MVC2。我在我的網址中傳遞了一個令牌。當我把它的正常工作的控制器,但我需要添加更多的參數「CID = X」mvc2是否可以在控制器的url級別添加參數?
代碼:
public ActionResult DetailPreferences(VMDetailPreferences vm)
{
if (!string.IsNullOrEmpty(Request["token"]))
{
GetDetails(Request["token"]);
return View(vm);
}
}
http://mydomain.com/Api/Al/DetailPreferences?token=12345但我想打電話給 http://mydomain.com/Api/Al/DetailPreferences?token=12345&Cid=x
是否有可能添加Cid = x?
您可以輕鬆地添加處理附加參數的路由。有一個很好的答案[這裏](http://stackoverflow.com/questions/2246481/routing-with-multiple-parameters-using-asp-net-mvc)告訴你如何做到這一點。 – DOK