Im new to MVC.
I have a controller for some charts (ChartsController), where I have an action result
public ActionResult TheChart { ...etc
I then have a View which displays the chart (its a Highcharts chart using javascript). This calls its data via this
public JsonResult GetData(string id) { ..etc
All works well.
I want to now add a parameter so that I can slightly change my javascript in the view for certain conditions. (Display for printing)
I was thinking something like
public ActionResult TheChart(string mediaType)
{
if (mediaType="print"){
ViewData["pdf"] = true;
}
}
Then I can grab this in the view.
The problem is that now my JsonResult doesnt work ( I think due to the routing ).
Any ideas of how to solve this?
it is because you have (string mediaType)
what you need is a new route like this:
this goes inside your Global.asax file incase you havent used these yet.