我认为这类似于How to disable binding of the route values in ASP.NET MVC?,但我不明白这个答案。
我在我的控制器中有一个代理操作,它看起来像这样
public ActionResult Proxy(string path) {
    // Issue a request to another server for the provided path
}像这样的路线规则
routes.MapRoute("Proxy", "Proxy/{*path}", new { controller = "Proxy", action = "Proxy" });这允许我将http://www.website.com/Proxy/some/path/here等代理请求代理到http://api.someotherwebsite.com/some/path/here,这样可以很好地工作。但是,如果我有查询参数(例如http://www.website.com/Proxy/some/path/here?x=1234 ),MVC试图将查询参数x绑定到代理操作,因此path参数最终得到的值是some/path/here而不是some/path/here?x=1234。如何防止这种行为并将查询参数包含在path参数中?
发布于 2013-08-16 18:13:00
老实说,与其试图处理自定义路由,不如直接将查询字符串追加到path参数中,这在您的情况下似乎要容易得多。
OtherServerRequest(path + "?" + Request.QueryString);
https://stackoverflow.com/questions/18279415
复制相似问题