B
Brybot
I have a form that i've split up into multiple aspanels, each panel
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.
To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:
foreach (IValidator validator in Page.Validators)
{
validator.Validate();
if (!validator.IsValid)
return;
}
This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length > 5
validates to true, even though it is not.
Any help would be greatly appreciated!
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.
To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:
foreach (IValidator validator in Page.Validators)
{
validator.Validate();
if (!validator.IsValid)
return;
}
This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length > 5
validates to true, even though it is not.
Any help would be greatly appreciated!