hholtij
hholtij

Reputation: 2936

Passing DateTimeOffset to WebAPI

My WebAPI method looks like this:

[Route("api/v1.0/Profile/Test/{offset}")]
public async Task<ServiceResult> GetTest(DateTimeOffset offset)
{
...
}

Calling it like this works: http://localhost:54295/api/v1.0/Profile/Test/2016-04-05T13:30:44-11:00

However, this call won't work: http://localhost:54295/api/v1.0/Profile/Test/2016-04-05T13:30:44+11:00

What's the trick here?

In my Web.config in the system.web section I have this entry:

<httpRuntime targetFramework="4.5" requestPathInvalidCharacters="&lt;,&gt;,%,&amp;,*,\,?" />

Upvotes: 2

Views: 1278

Answers (1)

hholtij
hholtij

Reputation: 2936

I found a solution:

In my web.config in the system.webServer section I added this block:

<security>
  <requestFiltering allowDoubleEscaping="true" />
</security>   

Now the plus sign works as desired.

Upvotes: 1

Related Questions