Search code examples
c#asp.net-mvcactionmethod

How to Pass Parameters to Action Method


I have a controller DPN and within that controller, I have an Action Method

[HttpGet]
public virtual ActionResult Report(string reportName)
{
   str_ReportPath = string.IsNullOrEmpty(str_ReportPath) ? "/BundleDealer/" + reportName : str_ReportPath;
   return View();
}

I want to know how can I pass a parameter to Report using Url.Action I tried this but got an error

<a href="@Url.Action(MVC.DPN.Report(), "AffiliateTFNDailySummary")">Provider</a>

Solution

  • Try this:

    <a href="@Url.Action("Report", "controller name", new { reportName = "AffiliateTFNDailySummary" })">Provider</a>