ClientScriptManager.RegisterForEventValidation

S

stewart

Hi.

I have an asp:dropdown control to which I add items on the client, when the
page is posted back I get this error message.
Invalid postback or callback argument. Event validation is enabled
using <pages enableEventValidation="true"/> in configuration or <%@
Page EnableEventValidation="true" %> in a page. For security purposes,
this feature verifies that arguments to postback or callback events
originate from the server control that originally rendered them. If
the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation


A quick trawl on google hasn't turned up much except that I could set
enableEventValidation=false, this does work, but I'm reluctant as I'm unsure
what security/checking this feature provides.
I can't find any examples(working) of how I could use
ClientScriptManager.RegisterForEventValidation instead of turning off event
validation to solve my problem.

Help please.....
 
B

Bruce Barker

event validation checks the event and value are legal for the current
postback.

background: asp 1.1 web sites had a common user coded security bug. many
asp.net coders would control access to their site by disabling, making
invisible, or changing the value of control that performed functions the
user was not allowed. the onclick events would not recheck permissions, so a
hacker could easily perform these functions by postiing a response that
faked the button/value press (trival to do).

so, in asp 2.0, the default is to only allow events for controls that were
enabled, visible at page render, and that the value (in the case of a
button and dropdowns,etc ) matched the renderd values.

in your case, .net is detecting that the value posted back was not on the
list that it rendered, thus its detecting a a client hack. as you site is
expecting this behavior, you need to turn off the default checking,
ClientScriptManager.RegisterForEventValidation can be used for this, rather
than turning it off for the whole page/site.

-- bruce (sqlwork.com)
 
S

stewart

Great Bruce, thanks for clarifying that for me.

--
Stewart Bellamy
Ingenuity@work
Bruce Barker said:
event validation checks the event and value are legal for the current
postback.

background: asp 1.1 web sites had a common user coded security bug. many
asp.net coders would control access to their site by disabling, making
invisible, or changing the value of control that performed functions the
user was not allowed. the onclick events would not recheck permissions, so
a hacker could easily perform these functions by postiing a response that
faked the button/value press (trival to do).

so, in asp 2.0, the default is to only allow events for controls that were
enabled, visible at page render, and that the value (in the case of a
button and dropdowns,etc ) matched the renderd values.

in your case, .net is detecting that the value posted back was not on the
list that it rendered, thus its detecting a a client hack. as you site is
expecting this behavior, you need to turn off the default checking,
ClientScriptManager.RegisterForEventValidation can be used for this,
rather than turning it off for the whole page/site.

-- bruce (sqlwork.com)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top