如何防止IIS不使用正斜杠更改反斜杠 [英] How to prevent IIS not to change backslashes with forward slashes
本文介绍了如何防止IIS不使用正斜杠更改反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用WebAPI2,我有一条路线Products / {Id} / details。
当Id包含\时,IIS会将其更改为 / 。
例如 pr\p 更改为 pr / p ,它会破坏uri。
我想知道如何防止将 **更改为** / ,还是有其他解决方法?
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?
谢谢提前帮助。
推荐答案
这看起来很有用:
<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>
这篇关于如何防止IIS不使用正斜杠更改反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文