Skip to: Site menu | Main content

Email LinkedIn


Odd URL variable behavior in ColdFusion

Ran into another issue (caused by me) with the IIS URL Rewrite module and ColdFusion.

A couple of our client applications utilize a REST API written in ColdFusion. It does not use the newly released built-in API in Coldfusion 2016. The REST url's are made possible by using the IIS URL Rewrite module. The module takes the rest API and then passes it to the ColdFusion API handler


<action type="Rewrite" url="/api/v1/api.cfm?resource={REQUEST_URI}" />

The custom API handler then parses the URL, FORM variables, and several other HTTP elements to process the request.

I noticed that when calling the API all but the FIRST URL variable was doubled.



In this case the variable anotherurlvariable would come across to ColdFusion with a value of "test,test".

The solution was pretty simple. I failed to use the URL Rewrite modules URLEncode function to correctly encode the URL (in my case resource) being passed to ColdFusion.

Updated URL Rewrite key (in web.config):

<action type="Rewrite" url="/api/v1/api.cfm?resource={UrlEncode:{REQUEST_URI}}" />

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)