【问题标题】:ASP MVC RedirectToAction redirect wrong when routes contains WebServiceHostFactory路由包含 WebServiceHostFactory 时 ASP MVC RedirectToAction 重定向错误
【发布时间】:2012-06-21 10:53:55
【问题描述】:

我有 ASP MVC 3 应用程序。我创建了 WCF REST JSON 服务,并通过 RegisterRoutes 方法中 Global.asax 文件中的下一个代码将其添加到我的应用程序中:

    routes.Add("Api", new ServiceRoute("api", new WebServiceHostFactory(), typeof     (ExternalApiService)));

服务很好,但是当我尝试使用时

    RedirectToAction("Index", "User", new { id = 1 });

我的控制器操作中的方法,它重定向到 (http://localhost:8091/api?action=Index&controller=User&id=1) url。

谁能帮我解决这个问题?

【问题讨论】:

  • 是的,我有带 id 参数的索引操作。

标签: c# asp.net-mvc asp.net-mvc-3 wcf asp.net-mvc-routing


【解决方案1】:

我认为您可能缺少路由约束。看看这个讨论Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 2023-03-28
    相关资源
    最近更新 更多