图像 url MVC 中的“&”会导致潜在危险的 Request.Path
我有一堆名称中包含&符号的图像。 我的网站是基于 Asp.net MVC3 构建的。
当我尝试查看其网址下方的图像时,我的网站返回并出现错误。
示例网址:
- www.somesite.com/myimages/an-%26-image.jpg
- www.somesite.com/myimages/an-&-image.jpg
返回错误: 从客户端 (&) 检测到潜在危险的 Request.Path 值。
这个问题还有解决办法吗?我真的不想关闭验证或恢复到 requestValidationMode="2.0" 正如我所看到的建议,因为这只是某些图像的问题。
所有图像都位于同一文件夹(myimages)中,是否可以停止对特定文件夹的验证?
I have a bunch of images that contain ampersands in their names.
My site is built on Asp.net MVC3.
When I try to view the image with they urls below my site returns and error.
Example urls:
- www.somesite.com/myimages/an-%26-image.jpg
- www.somesite.com/myimages/an-&-image.jpg
Error returned:
A potentially dangerous Request.Path value was detected from the client (&).
Is there away around this issue? I dont really want to turn off validation or revert to requestValidationMode="2.0" as i've seen suggested as this is only an issues with some images.
All the images are in the same folder (myimages), is it possible to stop validation on a particular folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以通过在 Web.config 中添加以下内容来解决此问题
。删除的只是
&
。我通过缩小这篇文章中需要解决该问题的部分来了解这一点。I was able to fix this by making the following addition to the Web.config
All that was removed was the
&
. I learned this by narrowing down which parts of this post were required to fix the problem.