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

  • Home
  • SEARCH
  • 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 6252535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:49:19+00:00 2026-05-24T13:49:19+00:00

Given the following URL: domain.com/page.aspx?id=123 How can I sanitize that query string value when

  • 0

Given the following URL:

domain.com/page.aspx?id=123

How can I sanitize that query string value when it is used on a Databound Control such as a repeaters SqlDataSource?

<asp:SqlDataSource ID="projectDataSource" runat="server" 
    ConnectionString="MyConnectionStrings" 
    SelectCommand="select foo from bar">
    <SelectParameters>
        <asp:QueryStringParameter 
            DefaultValue="0" 
            Name="idfromqs" 
            QueryStringField="id" 
            Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

Such that ?id=asdf does not result in an error?

These similar questions have good answers, but none of them seem to quite match my problem

  • Validate QueryStrings in ASP.NET (check occurs in code behind file)
  • How to intercept and pre-process QueryStrings in Asp.Net (seems to drastic for a simple check)

Note: This is an internal application that is limited to a small block of local ip address. I’m less worried about malicious sql injection and more about preventing less savvy users from seeming nasty error messages.

  • 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-24T13:49:21+00:00Added an answer on May 24, 2026 at 1:49 pm

    You could use the Selecting event of the SQLDataSource where you can check the querysting value. This event fires before the Select Method is called.

    protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        SqlDataSource1.SelectParameters.Clear(); //Clear existing parameters
        // based on your check, you can pass the default value
        SqlDataSource1.SelectParameters["idfromqs"].DefaultValue = "Set Value here";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given the following url: http://foo.com?bar=1&wee=2 What is the quickest way to get the raw
Given the following repository URL from my pom.xml how can I determine what the
Given the following code: using (var client = new WebClient()) { string url =
Given the following URL (working, try it!) https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524&currency=GBP&amount=1401.49&testMode=100&name=Tom%20Gul&address=24%20House%20Road \nSome Place\nCounty&postcode=TR33%20999&email=email@mail.com&country=GB If you click on
I've got the following object: $json = '{response: {status: {message: Success}, images: [{url: http://domain.com/images/0001.jpg},
I'm looking for some REGEX help Given the following URL: http://news.cnet.com/8301-13924_3-10315534-64.html?part=rss&subj=news&tag=2547-1_3-0-20 What is the
I am using Java with Spring framework. Given the following url: www.mydomain.com/contentitem/234 I need
Given the following javascript (jquery) $(#username).keyup(function () { selected.username = $(#username).val(); var url =
Given the following code, How would you refactor this so that the method search_word

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.