11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

268 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sRange ChecksSometimes you need to validate that input data falls within a predetermined range.The following code uses an ASP.NET RangeValidator control to constrain input towhole numbers between 0 <strong>and</strong> 255. This example also uses theRequiredFieldValidator. Without the RequiredFieldValidator, the other validatorcontrols accept blank input.The following example shows how to validate range using the Regex class:try{// The conversion will raise an exception if not valid.int i = Convert.ToInt32(sInput);if ((0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!