I ran into the following problem:
I've got a asp.net mvc 5 controller with a reference type as a parameter:
[Route("")]
[HttpGet]
public ActionResult GetFeeds(Location location)
{
if (location == null)
{
// init location or smth
}
// Do smth with location
return new EmptyResult();
}
You will notice that I'm using AttributeRouting. There are NO other methods with the name of this action.
However - this is my location class:
public class Location : ILocation
{
public DbGeography Coordinates { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
}
Nothing special here (the interface defines all of those properties).
If I'm accessing the controllers action (actually using powershell) and passing something like:
http://localhost:2000/Feed?latitude=23.1&longitude=37
everthing works fine but if I'm using
http://localhost:2000/Feed
the location parameter is NOT null (it is a new Location with default values), which is the behavior I want to have :( .
Does anyone have an idea why this happens?
Thanks in advance