I have a problem passing a list from my controller to a view.I have a controller with a method that returns a List of Locations.
public ActionResult Location()
{
List<Location> locations = db.Locations.ToList();
return View(locations);
}
And a View that receives this model and will do some stuff like setting this locations in a Map.
@model List<PMG.Models.Entities.Location>
<div id="map" style="height:500px"></div>
<script src="https://maps.googleapis.com/maps/api/js?...=initMap"></script>
But when my controller calls the view i get the error
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[PMG.Models.Entities.Location]', but this dictionary requires a model item of type 'PMG.Models.Entities.User'.
The problem is that my master layout expects a model of type PMG.Models.Entities.User and when i call my controler to load the view it refresh the whole site. How can i do so when i call the method only refresh the body section.
Now im calliung the view by calling the controller method in the way :
<a href="@Url.Action("Location", "Location")">Locations</a>
Thanks in advance