如何允许在 .NET 4 上使用带有数据 url 的内联图像而不触发请求验证?

发布于 2024-08-26 09:48:14 字数 805 浏览 3 评论 0原文

我在 ASP.NET MVC 2 项目中使用 jQuery jstree 插件 (http://jstree.com) .NET 4 RC,并在 IIS 7.5 上运行。它附带了一些带有内联图像和数据 url 的样式表,如下所示:

.tree-checkbox ul { 背景图像:url(数据:图像/gif;base64,R0lGODlhAgACAIAAAB4dGf///yH5BAEAAAEALAAAAAACAAIAAAICRF4AOw==); }

,背景图像的 url 包含冒​​号,.NET 4 认为这是一个不安全的字符,因此我收到以下错误消息:

潜在危险的Request.Path 从客户端检测到值 (:)。

根据文档,我应该能够通过添加来防止这种情况

<系统.web>


<系统.web>

到我的 Web.config,但这似乎没有帮助。我尝试将其添加到应用程序的主 Web.config 以及 /config 文件夹中的特殊 Web.config,但无济于事。

有什么办法让 .NET 允许这样做吗?

I'm using the jQuery jstree plugin (http://jstree.com) in a ASP.NET MVC 2 project on .NET 4 RC, and running on IIS 7.5. It comes with some stylesheets with inline images with data urls, like this:

.tree-checkbox ul {
background-image:url(data:image/gif;base64,R0lGODlhAgACAIAAAB4dGf///yH5BAEAAAEALAAAAAACAAIAAAICRF4AOw==);
}

Now, the url for the background image contains a colon, which .NET 4 thinks is an unsafe character, so I get this error message:

A potentially dangerous Request.Path
value was detected from the client
(:).

According to the documentation, I am supposed to be able to prevent this by adding

<system.web>
<httpRuntime requestValidationMode="2.0"/>
<pages validateRequest="false"/>
<system.web>

to my Web.config, but that doesn't seem to help. I have tried adding it to the main Web.config for the application, as well as to a special Web.config in the /config folder, but to no avail.

Is there any way to get .NET to allow this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠意 2024-09-02 09:48:14

你用的是IIS7吗?

IIS7 以不同的方式验证请求,您必须“恢复”其行为以忽略潜在危险的请求。

 <system.web>
    <httpRuntime requestValidationMode="2.0"/>
 </system.web>

Are you using IIS7?

IIS7 validates requests differently and you have to "revert" its behavior to ignore potentially dangerous requests.

 <system.web>
    <httpRuntime requestValidationMode="2.0"/>
 </system.web>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文