I have some javascript that calls an action method on a controller (MVC, C#) there are two parameters defined, both have values but I get a null reference exception. Heres the javascript that calls the action method
$("*[id^=popout1]").on("click", function () {
//debugger;
$(".FakeClass").dropdown('toggle');
var id = this.getAttribute("data-id");
var reportType = $('#ReportExecutionType').val();
var url = '@Url.Action("PopUp", "Benchmark", new { cid = "_id_" , reportName = "_ret_"})'.replace('_id_', id).replace("_ret_", reportType);
newwindow = window.open(url, 'name', 'height=800,width=850');
if (window.focus) { newwindow.focus() }
return false;
});
and this is the url thats generated
"/Benchmark/PopUp?cid=113&reportName=17"
this is the c# action method
[LayoutInjecter("_EmptyLayoutPage")]
[HttpGet]
public async Task<ActionResult> PopUp(int cid, Helpers.EnumHelper.Reports reportName)
{
return View("PopUp", await PopulateResponse(cid, reportName));
}
but I get this error
The parameters dictionary contains a null entry for parameter 'reportName' of non-nullable type 'Common.Helpers.EnumHelper+Reports' for method 'System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult] PopUp(Int32, Reports)' in 'Controllers.Benchmark.BenchmarkController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
I cant figure this one out, the parameter isn't misspelled and it has a value, so why am I getting this error ?