Search code examples
razormodel-view-controllercontrolleractionlink

Parameter name is null when passing from ActionLink to Controller


I have a strange problem:

I have an ActionLink in the view :

   @Html.ActionLink("Signature", "DownloadDocumentFile", "Home", new { fileName = "Sem Szabi.jpg" })

Although the fileName is set, in the controller method the fileName is always null enter image description here

In most cases the problem is that the parameter name does not match, but in my case the parameter name is the same in the view, and in the controller, too. Can you advise?


Solution

  • Try with below link.

    @Html.ActionLink("Signature", "DownloadDocumentFile", new { fileName = "Sem Szabi.jpg" })

    The below is also useful.

    @Html.ActionLink("Signature", "DownloadDocumentFile","Home", new { fileName = "Sem Szabi.jpg" },new { })