How to prevent IIS not to change backslashes with forward slashes

不羁岁月 提交于 2019-12-22 09:55:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!