0

I would like to pass a date string to a web service for testing, using a browser. I've tried Chrome and Firefox and both error out with this:

Server Error in '/' Application.
A potentially dangerous Request.Path value was detected from the client (:

The web service (RESTful) is accessed like this:

http://localhost:52936/Accounts/mod_date/2015-05-13T15%3A15%3A19

I've tried enclosing the date in quotes, but get the same error. Is this possible?

Ron
  • 2,435
  • 3
  • 25
  • 34

1 Answers1

0

Try a QueryString Parameter

Since you are just performing testing, you should be able to pass your stringified DateTime value as a querystring parameter and it should avoid your service throwing a fit :

/Accounts/mod_date?yourDateParameterName=2015-05-13T15:15:19

Or if you wanted a more in-depth approach, you could consider using a suggestion like the one mentioned in this related discussion.

Explicitly Allow : Characters

Scott Hanselman covers the idea of explicitly allowing certain characters to be passed to a service via a URL in this blog post. It basically allows you to define which values are considered "dangerous" when passed in and would simply involve you changing the requestPathInvalidCharacters setting within the web.config of your application from :

<httpruntime requestvalidationmode="2.0">
         requestPathInvalidCharacters="<,>,*,%,:,&,\"
         />
</httpruntime>

to :

<!-- Removes the colon ':' as a dangerous parameter -->
<httpruntime requestvalidationmode="2.0">
         requestPathInvalidCharacters="<,>,*,%,&,\"
         />
</httpruntime>

This is obviously very controversial stuff and may not be useful for all scenarios, but it is an option.

Consider Postman (for Testing)

Additionally for testing purposes, you might consider using a service like Postman, which is ideal for performing this type of API testing.

Community
  • 1
  • 1
Rion Williams
  • 74,820
  • 37
  • 200
  • 327
  • That worked: I edited web.config to include this: but (for some reason) had to delete other httpRunTime config parameters. Still it now works. – Ron Apr 21 '16 at 18:31