ASP.Net 动态数据站点中的 Xml 数据

发布于 2024-07-13 16:26:40 字数 766 浏览 5 评论 0原文

我遇到这个问题,无法让动态数据 Web 应用程序将 xml 数据保存到文本字段中。 也许这是一个常见问题,但搜索网络并没有给我任何答案......

所以这里是重新创建我的问题的步骤:

  • 我有一个数据库,其中有一个表,其中有一列类型为“ntext”(Sql Server 2005)。
  • 我创建一个新的动态数据实体 Web 应用程序,在其中创建一个 ADO 实体数据模型并添加带有 ntext 列的表。
  • 我设置了 global.ascx 文件并启动了 Web 应用程序。
  • 当 Web 应用程序打开时,我导航到表并插入一个新项目。
  • 在生成的代表 ntext 列的文本框中,我插入一些 xml(从记事本简单剪切和粘贴),然后单击“插入/保存”按钮。
  • 插入失败并出现错误:

    Microsoft JScript 运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:在服务器上处理请求时发生未知错误。 从服务器返回的状态代码为:500

尝试的 xml 示例

<?xml version="1.0" encoding="utf-8"?>
<root>
<item></item>
</root>

键入字符串,例如“hello world”有效!

谁能帮助并告诉我哪里出错了?

谢谢

I have this problem where I can't get my dynamic data web app to save xml data into a text field. Maybe this is a common problem but searching the web doesn't give me any answers...

So heres the steps to recreate my problem:

  • I have database with a table that has a column of type "ntext" (Sql Server 2005).
  • I create a new Dynamic Data Entities Web Application, within this I create an ADO Entity Data Model and add the table with the ntext column.
  • I setup the global.ascx file and fire up the web app.
  • When the web app opens I navigate to the table and insert a new item
  • In the text box thats generated and represents the ntext column, i insert some xml (simple cut and paste from Notepad) and hit the Insert/Save button.
  • The insert fails with a the error:

    Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

Example of xml attempted

<?xml version="1.0" encoding="utf-8"?>
<root>
<item></item>
</root>

Typing a string of characters eg "hello world" works!

Can anyone help and tell me where I'm going wrong?

Thanks

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

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

发布评论

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

评论(3

眉目亦如画i 2024-07-20 16:26:40

只是作为旁注。

IMO,应尽可能避免为所有页面设置 validateRequest="false"。 每当您遇到必须禁用它的情况时,请在页面级别上设置它(<%@ Page ValidateRequest="false" ..%>。

另外,在执行此操作的页面上,确保您正在验证输入,这样就不会传递任何有害内容。

Just as a sidenote.

Setting validateRequest="false" for all the pages should be avoided when possible, IMO. Whenever you've a scenario where you've to disable it, set it on the page level ( <%@ Page ValidateRequest="false" ..%>.

Also, on the pages where you do this, make sure you're validating the input, so nothing harmful gets passed on.

姜生凉生 2024-07-20 16:26:40

这可能是因为它看到您在潜在危险请求中添加的内容。 我假设您在页面指令中有 ValidateRequest="true" 。 它是否正确?

It is probably becuase it sees what you are adding in a potential dangerous request. I would assume you have ValidateRequest="true" in the page directive. Is this correct?

那小子欠揍 2024-07-20 16:26:40

我只能说 REA_ANDREW 你是个天才! 我在 web.config 中更新了它,现在它可以工作了:

<pages validateRequest="false">

Can i just say REA_ANDREW you're a genius! I updated this at the web.config and it now works:

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