0

I have the following problem: I make the call to the method of a controller, it receives a parameter. The code is as follows:

@Html.ActionLink("Preview", "ReportExecution", "Report", new { reportName = ViewBag.docLiquidation }, null) 

This generates me the following address:

http://localhost:65500/Report/ReportExecution/docRetentionDeclaration

docRetentionDeclaration identified as a parameter, but does not.

The code of the method is as follows:

[HttpPost]
public FileResult ReportExecution(string reportName)
{
     .
     .
     return new File();
}

I appreciate the help you can give me.

jorcast
  • 15
  • 1
  • 7

1 Answers1

0

Assuming you have the following route:

routes.MapRoute(
    "Default",
    "{controller}/{action}/{reportName}",
    new { controller = "Home", action = "Index", reportName = UrlParameter.Optional }
);

the controller action will expect the parameter to be called reportName:

public ActionResult ReportExecution(string reportName)
{
    ...
}

Notice how the parameter name of the controller action must match the route token in your route definition.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Sure, the name of the parameter corresponds to the route. [HttpPost] public FileResult ReportExecution(string reportName) – jorcast Jun 28 '12 at 16:58
  • 3
    `[HttpPost]`???? And how do you expect to invoke a method that accepts only the POST verb with an anchor? – Darin Dimitrov Jun 28 '12 at 17:01