I am working on a javascript functionality of passing complex data from window.open() to MVC Controller action method parameter. I was able to achieve it by constructing a query string and retrieving them from [FromQuery] in controller.
But my problem is I want to pass the data as a model object. Is it possible in window.open()
Below is my javascript code
$("#btnExportToExcelForBatch").on('click',
function() {
var currentBatchId = 0;
var empName = $("#empName").val();
var empId = $("#empId").val();
var deptId = $("#deptId").val();
window.open("/Download/ExportToExcel?EmpName="
+ empName + "&EmpId=" + empId + "&DeptId="
+ deptId);
});
As you can see, I can pass the data in the URL, but it seems to be exposed. So, is there way that I can pass in
var url = @Url.Action("ExportToExcel", "Download");
But I am unable to pass them.
Is there a possible way to achieve by sending as model object to MVC controller.
public async Task<IActionResult> ExportToExcel(EmployeeModel employeeModel)
{
// SomeCode
return File();
}
Could anyone help me with this problem