0

我有一个可以点击的 Actionlink。它应该将发票编号传递给我的控制器中名为 Report 的方法。我为此创建了一条路线,如下所示。目前,我无法使用传递的参数点击 Report 方法。什么都没发生。我的页面只是闪烁。我错过了什么?

             @foreach (var objUser in Model.Invoices)
             {
                    <tr>            
                        <td><input type="checkbox" name="ckCheck" /></td>
                        <td>@objUser.invoiceDate</td>                 
                        <td>@Html.ActionLink(objUser.invoiceNumber, "Report", new { id = objUser.invoiceNumber }) </td>
                        <td>@objUser.accountNumber</td>
                        <td>@String.Format("{0:#,0.00}", objUser.amount)</td>
                        <td>@String.Format("{0:#,0.00}", objUser.amountDue)</td>
                    </tr>
             }


              public static void RegisterRoutes(RouteCollection routes)
                    {
                        var routeProvider = PluginLocator.GetPlugin<IRouteProvider>();
                        routes.MapRoute(null, "Invoice", new { controller = "Invoice", action = "Report" });
                        routeProvider.RegisterRoutes(routes); 
                    }


              public ActionResult Report(int id = 0)
                    {           
                        ReportClass rptH = new ReportClass();
                        rptH.FileName = Server.MapPath("/myreport/ourReport.rpt");
                        rptH.Load();
                        rptH.SetDatabaseLogon("zombie", "zombie29");
                        rptH.SetParameterValue("PARAM_REPORT_RUN_ID", id);
                        Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                        return File(stream, "application/pdf");
                    }
4

1 回答 1

0

这对我有用。

 routes.MapRoute(null, "Invoice/{action}", new { controller = "Invoice", 
                                                            action = "Index" });

引入“Invoice/{action}"使其工作。

于 2013-08-30T12:45:31.723 回答