我有一个应该可点击的Actionlink。它应该通过发票号码 到我的控制器中称为报告的方法。我为此创建了一条路线并显示出来 下面。 目前我无法使用传递的参数来命中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");
}
答案 0 :(得分:0)
这对我有用。
routes.MapRoute(null, "Invoice/{action}", new { controller = "Invoice",
action = "Index" });
介绍“Invoice/{action}"
让它发挥作用。