我保存了一个包含% and %20
当我点击指向此文件的链接时。使用javascript正在进行encodeURI(filePath)
。
找不到文件错误,但文件可用。
浏览器Chrome和IE,服务器:IIS服务器
实际URl:http://<servername>/<Folder>/PDF/!%2-!@crackerunit&%_20151029203000_0.pdf
encodedURl:http://<servername>/<Folder>/PDF/!%252-!@crackerunit&%25_20151029203000_0.pdf
答案 0 :(得分:0)
请按照以下步骤操作:
1. Original pdf: !%2-!@crackerunit&%_20151029203000_0.pdf
Use JavaScript encodeURI: encodeURI("!%2-!@crackerunit&%_20151029203000_0")
Resulting output: !%252-!@crackerunit&%25_20151029203000_0.pdf
Complete url: http://<servername>/<Folder>/PDF/!%252-!@crackerunit&%25_20151029203000_0.pdf
Once this url is accessed, you receive an exception: A potentially
dangerous Request. Path
value was detected from the client (%). Solve this problem by following
step2
2. web.config changes:
<system.web>
<httpRuntime requestPathInvalidCharacters=""
/>
</system.web>