Not able to pass Datetime in $.Param() querystring to MVC Controller Get
Method....
Angularjs Api Code:
exportFunt = function () {
var query = generateExportData();
Export(query);
};
function generateExportData() {
return {
startDate: viewModel.StartDate,
endDate: viewModel.EndDate,
};
}
Export: function (query) {
$window.open('/demo/analysis/test?$.param(query),
'_blank');
}
Output url link:
/demo/analysis/test?startDate=Sat+Jun+01+2013+00%3A00%3A00+GMT-0700+(Pacific+Daylight+Time)&endDate=Fri+Sep+13+2013+00%3A00%3A00+GMT-0700+(Pacific+Daylight+Time)
test controller:
Public Function GetData(<FromUri()> ByVal query As Request) As
HttpResponseMessage
{
}
Request{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
The issue is that I am not able to get the Start & End Dates in the query
object. I can see it in the url so I think that the angular Api is passing
is correctly but there is something wrong with the formating. I also tried
to do JSON.stringify(query) & then send it using encodeURIComponent(result
of JSON stringify) but that did'nt work either. I am curretly getting
default data 1/1/0001 in the start & end date query obj.
I am sorry but I cannot paste the whole API so I had to extract the
related code and paste it here.. If you think I am missing anything please
let me know..but I think the issue is surely somewhere in the above code..
Thanks for the Concern...
No comments:
Post a Comment