views:

649

answers:

3

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

A: 

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?

REA_ANDREW
A: 

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

<pages validateRequest="false">
Thanks, I would love that to be true. May be in another 40 years I may get close. I agree with snomag, and I apologise for not making clear that my intention was to convey its usage a page level not globally. Apologies for that.
REA_ANDREW
A: 

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.

snomag