问题
I am using WebAPI2 and I have a route "Products/{Id}/details". When Id contains \ , IIS changes it to /. For example pr\p is changed to pr/p and it "spoils" the uri. I want to know how to prevent changing ** to **/, or are there any other workarounds?
Thanks in advance for your help.
回答1:
This looks useful:
<rule name="KeepBackslashes" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://HOST:PORT/{UrlDecode:{C:1}}" logRewrittenUrl="true" />
<conditions>
<add input="{UNENCODED_URL}" pattern="/(.*?)($|\?)" />
</conditions>
</rule>
来源:https://stackoverflow.com/questions/29792060/how-to-prevent-iis-not-to-change-backslashes-with-forward-slashes