使用Url.Action时的路由

时间:2018-05-04 16:05:00

标签: c# asp.net asp.net-mvc razor

所有

我有以下代码,但没有创建预期路线。

[RoutePrefix("widgets")]
public class PublishedReportWidgetController : Controller

    [Route("published-reports"), HttpGet]
    public ActionResult PublishedReports()

    [Route("published-reports/{publishedReportId}"), HttpGet]
    public ActionResult PublishedReports(int publishedReportId)

现在在我看来,我有以下内容:

console.log("@(Url.Action("PublishedReports", "PublishedReportsWidget"))");
console.log("@(Url.Action("PublishedReports", "PublishedReportsWidget", new { id = 9999 }))");

现在为什么不输出路线“/ widgets / published-reports / 9999”?

我看到输出“widgets / published-reports?9999”后跟“/ widgets / published-reports”

THX jonpfl

1 个答案:

答案 0 :(得分:-1)

我已经弄清楚了,我猜这个词'id'与'publishedReportId'导致了这个问题。