zaria khan zaria khan - 1 month ago 11
C# Question

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 getting error

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

Answer

Try this:

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