I have route:
config.Routes.MapHttpRoute(
name: "RestApi",
routeTemplate: "rest/{storage}/{controller}/{id}/{action}",
defaults: new
{
id = RouteParameter.Optional,
action = "Index"
}
{id} parameter can be URI itself, and I encode it. For example, route can be: /rest/main/nodes/http%3A%2F%2Fwww.company.com%2Fns%2FGeo%23United_States/rdf
But this way wrong, it isn't work. With simple {id} parameter it is OK.
What I should do to make it works?
What I should do to make it works?
Just use query string parameters if you intend to send arbitrary characters to the server:
/rest/main/nodes/rdf?url=http%3A%2F%2Fwww.company.com%2Fns%2FGeo%23United_States
You may read the following blog post from Scott Hanselmann in which he covers the difficulties of using such values in the path portion of the url.
I quote his conclusion:
After ALL this effort to get crazy stuff in the Request Path, it's worth mentioning that simply keeping the values as a part of the Query String (remember WAY back at the beginning of this post?) is easier, cleaner, more flexible, and more secure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With