I'm creating a RESTful API with ASP.Net MVC
Have problem with one GET route. I created a parameters model to handle all receiving params.
public class MyParameters : BaseParameters
{
public string ProductCode { get; set; }
...
}
and using this class in this way:
public HttpResponseMessage Get([FromUri] MyParameters filter)
The problem is when i don't pass any parameters - the filter object not being initialized. It is always null.
But I need this object to be initialized anyway, because there are some default parameters, like flags, which I initialize in constructor.
public MyParameters()
{
AuthFlag = 'Y';
}
I know that it is default behaviour, but I don't want to do something like this:
if (filter == null)
filter = new MyParameters();
Maybe Is there any configuration available to make parameters objects created anyway?
Thank you for any suggestions.