Javascript 即使在url编码之后,也无法下载包含%的文件
我保存了一个文件,其中包含Javascript 即使在url编码之后,也无法下载包含%的文件,javascript,urlencode,url-encoding,Javascript,Urlencode,Url Encoding,我保存了一个文件,其中包含%和%20 当我单击指向此文件的链接时。通过使用javascript,我在做encodeURI(filePath) 获取未找到文件错误,但文件可用 浏览器Chrome和IE,服务器:IIS服务器 实际URl:http:////PDF/!%2-!@Cracker Unit&%\u 20151029203000\u 0.pdf encodedURl:http:////PDF/!%252-!@crackerunit&%25\u 20151029203000\u 0.pdf遵循
%和%20
当我单击指向此文件的链接时。通过使用javascript,我在做encodeURI(filePath)
获取未找到文件错误,但文件可用
浏览器Chrome和IE,服务器:IIS服务器
实际URl:http:////PDF/!%2-!@Cracker Unit&%\u 20151029203000\u 0.pdf
encodedURl:http:////PDF/!%252-!@crackerunit&%25\u 20151029203000\u 0.pdf
遵循以下步骤:
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>
1。原始pdf:!%2-!@饼干单位&%\u 20151029203000\u 0.pdf
使用JavaScript encodeURI:encodeURI(!%2-!@crackerunit&%\u 20151029203000\u 0)
结果输出:!%252-!@饼干单位和%25_20151029203000_0.pdf
完整url:http:////PDF/!%252-!@饼干单位和%25_20151029203000_0.pdf
访问此url后,您将收到一个异常:一个
危险的请求。路径
从客户端检测到值(%)。通过以下方法解决此问题
步骤二
2.web.config更改:
遵循以下步骤:
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>
1。原始pdf:!%2-!@饼干单位&%\u 20151029203000\u 0.pdf
使用JavaScript encodeURI:encodeURI(!%2-!@crackerunit&%\u 20151029203000\u 0)
结果输出:!%252-!@饼干单位和%25_20151029203000_0.pdf
完整url:http:////PDF/!%252-!@饼干单位和%25_20151029203000_0.pdf
访问此url后,您将收到一个异常:一个
危险的请求。路径
从客户端检测到值(%)。通过以下方法解决此问题
步骤二
2.web.config更改:
您是否尝试过改用encodeURIComponent()呢?参考这篇文章。我没有任何查询字符串值,因此我使用encodeURI()
请显示实际代码。您使用的是哪台服务器?哪个浏览器?你能发布你正在使用的代码吗?你试过使用encodeURIComponent()吗?参考这篇文章。我没有任何查询字符串值,因此我使用encodeURI()
请显示实际代码。您使用的是哪台服务器?哪个浏览器?你能发布你正在使用的代码吗?但是escape已经贬值了。但是escape已经贬值了。