Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 503671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:25:04+00:00 2026-05-13T06:25:04+00:00

Consider the following scenario: http://www.yourdomain.com/Default.aspx?p=2 Now we ofcourse want to check if the querystring

  • 0

Consider the following scenario:
http://www.yourdomain.com/Default.aspx?p=2

Now we ofcourse want to check if the querystring parameter p doesnt contain errors.
I now have this setup:

1) Check if p exists

2) Filter out html from p’s value

3) htmlencode p’s value

4) check if p is integer

5) check if p’s integer exists in db

This is how I usual do it, though step 5 is ofcourse a performance hit.

Kind regards,
Mark

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:25:04+00:00Added an answer on May 13, 2026 at 6:25 am

    Quite simple. For most data types (integers, decimals, doubles, dates and booleans) there is a very strict format. If the value does not parse under the strict format, it’s an error.

    Strings sometimes have a strict format, like an email address or a phone number. Those can be validated with a simple regexp. If it conforms, use it, otherwise it’s an error.

    Most of the time however strings will simply need to be persisted to the DB and later displayed again. In that case no processing is needed, aside from escaping when inserting into DB (unnecessary as well if you used parametrized queries)k, and HTML-encoding when rendering to the display.

    This way any and all data is validated, and there is no risk of any injections whatsoever.

    The rare exception of a loose format for a string is, well… rare. I can’t think of any right now. For that you can afford some more extensive parsing and processing.

    Added: Oh, yes, checking whether IDs (or other values) are valid in respect to a DB. You’re doing it right, but think if you always need it. Quite often you can put the check into some other query that you have to do anyway. Like when you select data based on the ID, you don’t need to explicitly check that it exists – just be ready that your query can return no data.

    Sometimes you don’t need to use the value at all, then you can simply ignore it.

    But, of course, there are other times, like when inserting/updating data, that you indeed need to explicitly check whether the data exists and is valid in the current context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following scenario: I want to be able to access http://www.example.com/word/hello/ , where
Consider the following scenario: http://www.restserver.com/example.php returns some content that I want to work with
Consider the following scenario: I own www.a.com , and in my index page I
I want to create an android app. please consider the following scenario: Iam standing
I was reading the following blogs about ASP.Net Async pages http://msdn.microsoft.com/en-us/magazine/cc163725.aspx http://world.episerver.com/Blogs/Magnus-Rahl/Dates/2012/1/Async-Pages-part-3-Async-Pages-with-databinding-and-events/ And a
Consider the following scenario: element.css({display:'none'}); element.slideDown(1000); // ... // here I want to get
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider the following scenario: /** * A sample interface. */ public interface MyInterface {
Consider the following scenario We have a simple database that involves two entities: user
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.