Xml web control and request validation error

Discussion in 'ASP .Net' started by Aamir Ghanchi, Mar 20, 2008.

  1. Hi,

    I hope there is a solution for this other than lowering guard by
    turning off ValidateRequest property of the page (or in webconfig)

    On page load I move xml string value into an Xml web control's
    DocumentContent property (not the XmlDataSource) and enableviewstate
    to true. When the page posts back, I get the error as follows:

    "A potentially dangerous Request.Form value was detected from the
    client ..."

    It's obviously freaking out on the angled brackets in the content.
    Being an asp control I thought it should be given a special treatment
    by asp through some internal encodeing etc. I tried HtmlEncode, but it
    will throw some other xml exception of being not well formed or
    msissing root. Any way I gave up and am using a HiddenField instead to
    hold the value between the trips, but it would be nice to use xml
    control to hold xml data.

    Any ideas?

    TIA
     
    Aamir Ghanchi, Mar 20, 2008
    #1
    1. Advertising

  2. Well, as you've discovered, you don't have to use an Xml Control. In fact,
    you don't need any control at all to "hold" the Xml string - you could store
    it in Session state.
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "Aamir Ghanchi" wrote:

    > Hi,
    >
    > I hope there is a solution for this other than lowering guard by
    > turning off ValidateRequest property of the page (or in webconfig)
    >
    > On page load I move xml string value into an Xml web control's
    > DocumentContent property (not the XmlDataSource) and enableviewstate
    > to true. When the page posts back, I get the error as follows:
    >
    > "A potentially dangerous Request.Form value was detected from the
    > client ..."
    >
    > It's obviously freaking out on the angled brackets in the content.
    > Being an asp control I thought it should be given a special treatment
    > by asp through some internal encodeing etc. I tried HtmlEncode, but it
    > will throw some other xml exception of being not well formed or
    > msissing root. Any way I gave up and am using a HiddenField instead to
    > hold the value between the trips, but it would be nice to use xml
    > control to hold xml data.
    >
    > Any ideas?
    >
    > TIA
    >
    >
    >
     
    Peter Bromberg [C# MVP], Mar 20, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,098
    John Saunders
    Oct 16, 2003
  2. Lucas Tam
    Replies:
    2
    Views:
    1,124
    Lucas Tam
    Feb 26, 2004
  3. javadude
    Replies:
    0
    Views:
    733
    javadude
    Feb 16, 2005
  4. Andy
    Replies:
    0
    Views:
    550
  5. KaR
    Replies:
    1
    Views:
    489
Loading...

Share This Page