AttributeRouting
AttributeRouting copied to clipboard
Route resolving with urlencoded forward slashes as parameter
Hello,
I'm developing a web api interface. Therefore I setup a HttpSelfHostServer and use attributerouting for route resolving. All works fine until I pass a parameter which contains a urlencoded forward slash. The request seems to be url decoded before routing rules are applied. Therefore routing the requests fail.
For last parameter on the URI I can workaround it by adding a catch all parameters like: [GET("Level1/{queryparameter1}/Level2/{*queryparameter2}")]
However for queryparameter1 I should also be able to pass a (url encoded) parameter value containing a forward slash.
I tried to implement a messagehandler to interfere with the automatically decoded parameters but this didn't work out.
For WCF there is a config setting to work around this:
Is there something simular available for ASP.NET web api?
Regards,
Jeroen
Jeroen, it seems your config setting example is missing.
Hi, the config is there but is made invisible. This config setting is described here: http://msdn.microsoft.com/en-us/library/ee656542.aspx
Would you please explain the reason for the slash in queryparameter1?
With the route in the example we navigate from entity 'queryparameter1' to a related entity 'queryparameter2'. The entities are both identified by an identification containing one or more forward slashes. So for instance 'auth://entity/1' This is url encoded but despite that causing problems when webapi / attributerouting determines the method for the route. Possibly because it url-decodes the url before processing.