I have a Base64 encoded uri that I send in a path parameter. It has no illegal characters (I've formatted it properly and checked to make sure). However, it's about 300-400 characters long.
When I send a DELETE request to this address using the long base64 parameter, I get a 400 BAD STATUS, INVALID URL response. When shortening the parameter, it works. I suspect that there is a max path problem?
Using a query string in place of a path parameter works, but I'd rather stay with the RESTful approach. Is there a config setting I can change on my Web API project to allow longer path-based parameters?
As you see clearly yourself: the long path is no issue.
Do you have a fitting route for your not working approach? It won't be caught by the default route. Your first will, because query parameter are not considered when routing.
jskiles1
Member
1 Points
3 Posts
Long path parameters causing 400 BAD REQUEST
Dec 09, 2012 03:26 AM|LINK
I have a Base64 encoded uri that I send in a path parameter. It has no illegal characters (I've formatted it properly and checked to make sure). However, it's about 300-400 characters long.
When I send a DELETE request to this address using the long base64 parameter, I get a 400 BAD STATUS, INVALID URL response. When shortening the parameter, it works. I suspect that there is a max path problem?
Using a query string in place of a path parameter works, but I'd rather stay with the RESTful approach. Is there a config setting I can change on my Web API project to allow longer path-based parameters?
This works:
This does not work:
MartinJ.
Member
243 Points
80 Posts
Re: Long path parameters causing 400 BAD REQUEST
Dec 09, 2012 07:37 AM|LINK
As you see clearly yourself: the long path is no issue.
Do you have a fitting route for your not working approach? It won't be caught by the default route. Your first will, because query parameter are not considered when routing.
jskiles1
Member
1 Points
3 Posts
Re: Long path parameters causing 400 BAD REQUEST
Dec 09, 2012 04:28 PM|LINK
Yes, I have this route defined:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}/{uri}",
defaults: new { id = RouteParameter.Optional, uri = RouteParameter.Optional }
);
I believe this may be related to the MAX_PATH limitations of Windows.
http://stackoverflow.com/questions/8447698/the-request-url-is-invalid-in-iis-7
http://stackoverflow.com/questions/1185739/asp-net-mvc-url-routing-maximum-path-url-length
http://social.msdn.microsoft.com/Forums/nl/netfxnetcom/thread/723e6bfd-cab7-417b-b487-67f1dcfa524f
jskiles1
Member
1 Points
3 Posts
Re: Long path parameters causing 400 BAD REQUEST
Dec 20, 2012 05:45 PM|LINK
Bump.