Reputation: 1115
I have an API that takes in a date time as a query string. Date is provided with a Time Zone indicator. When I pass the date with with a "+"in time zone i am getting the default value of a Date Time.
I tried a very simple API that only takes a date from Query String a parameter.
When I pass the date
2019-03-12 07:00:00+05:00
I receive the error :
"The value '2019-03-12 07:00:00 05:00' is not valid."
It looks like the "+"is not interpreted. With a "-" like
2019-03-12 07:00:00-05:00
It works well
It looks like we can't pass a "+" in a query string. How are you suppose to a pass date time with zone indicator in the query string ?
Upvotes: 0
Views: 38
Reputation: 23819
The plus sign in a query string means the space character. %2B
is the URL encoded version of +
and what you want.
Depending on where you are creating this URL, your can use System.Net.WebUtility.UrlEncode(...)
to escape any other characters that need this treatment, as well as the plus sign.
Upvotes: 0
Reputation: 239460
You have to urlencode the +
, since +
means "space" in a URL. This should in fact happen for you automatically if you're using a tag helper or something like Html.Action
, Url.Action
, etc. If you're passing it manually, then it's on you to manually urlencode it.
Upvotes: 2