我注意到,使用.NET MVC站点,您可以使用多个正斜杠命中URL,例如:
http://www.example.com//category
http://www.example.com//category//product
Run Code Online (Sandbox Code Playgroud)
URL加载正常,一切正常,但是,我被要求阻止这种情况发生.
我一直在尝试使用IIS URL重写来使其工作:
<rewrite>
<rules>
<rule name="Remove multiple slashes" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{UNENCODED_URL}" matchType="Pattern" pattern="^(.*)//(.*)$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{C:1}/{C:2}" />
</rule>
</rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)
然而,结果似乎很有气质.有时产品URL会重定向,有时它不会和类别一样.这几乎就像应用程序正在缓存URL一样.
有没有人知道我是否可以禁用任何缓存,或者是否有其他方法来解决这个多次斜杠问题?
任何帮助深表感谢.