c# - Nullable DateTimeOffset fromuri parameter in webapi 2 not working -
given action this:
public async task<ihttpactionresult> getstatus(string dataflowid, [fromuri] datetimeoffset? lasttime = null) and client code uri accessing action:
datetimeoffset? lastly = somedatetime; /* request */ new uri( flow.statusuri + (last.hasvalue? "?lasttime="+last.value.tostring():"")); an exception raized cant convert nullable'1 lasttime.
what needed instead of tostring() on client site webapi 2 able datetime querystring
{"message":"the request invalid.","modelstate":{"lasttime":["the value '1/1/1601 12:00:00 00:00' not valid nullable`1."]}}
using uri.escapedatastring solved issue.
new uri(flow.statusuri + (last.hasvalue? "?lasttime="+uri.escapedatastring(last.value.tostring()):"")) c# asp.net-web-api
No comments:
Post a Comment