asp.net - 检测到潜在危险的 Request.Form 值

标签 asp.net xml http-post

我正在使用 php 脚本将一些 xml 文件 http 发布到 .net URL。

当我提交时,我得到了回复:

A potentially dangerous Request.Form value was detected from the client (<?xml version="...UTF-8"?> <!DOCTYPE cXML SYSTE..."). Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

因为我没有使用 .NET,所以我无法在 web.config 中设置 ValidateRequest="false"。

我需要在提交之前清理我的 xml 吗?我该怎么做?

最佳答案

有趣的是,您可以看到完整的错误,但无法访问 ASP.NET 代码。通常,只有在 Debug模式下才能看到完整的错误,因为在生产中,错误设置是(应该)RemoteOnlyOff .这似乎是 ASP.NET 站点的配置错误和潜在风险。

你说 “通过 http 发布一些 xml 文件”。如果您确实发布了文件,您将不会收到此回复。或许您可以联系该站点的所有者并要求他更改表单以允许文件输入。

您可以更改您的输入,使其看起来不再像 XML,但它也不再是 XML。即,更改所有 <&lt;并且您将能够通过您的数据,但在处理时必须未转义。

如果此站点应该接受 XML,则必须将其更改为接受 XML。它应该接受文件,或者它应该通过转动 ValidateRequest 来接受 HTML/XML 输入。关闭。如果它不应该接收 XML,您将无能为力。这就像通过在金额字段中输入字母来填写银行的付款表格:它根本行不通(除非它被设计成那样工作)。

关于asp.net - 检测到潜在危险的 Request.Form 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3492080/

相关文章:

node.js - 招摇: is '😱 Could not render this component, see the console' an error message or can it be ignored

c# - 从 ASP.NET 中的另一个源获取字符串形式的发布数据

asp.net - XSD 文件无法在 Visual Studio 2017 的表设计模式下打开

android - coverflow 未显示在 Android 的 xml 布局上

XML 转义字符

java - 如何在 Spring 4.2 或更高版本中设置 Cache-control : private with applicationContext. xml

java - 发送 HTTP POST - Android

asp.net - 将 cookie 过期设置为 DateTime.Max(9999 年 12 月 31 日)时出现问题?

c# - 我如何从中继器控件中获取最后一个记录值?

c# - 在 ASP.NET 的类中有 Response.Redirect 的坏习惯?