Advertisement

04.29.2008 at 10:04AM PDT, ID: 23362730
[x]
Attachment Details

Catching the exception thrown by a SqlDataSource when taking Query string input

Asked by McExp in C# Programming Language, Programming for ASP.NET, .NET Framework 2.0

Take this example, I hae a Gridview that is bound to a SqlDataSource that has a Select statment which uses a Request Parameter in it's where clause.

If this data is of the correct format everything works fine. However If the input is not the integer that I was expecting but a string of random characters, How do I Trap this before it throws an exception and fails?

I've considered Hooking the Selecting event on the SqlDataSource and canceling the command if the paramter is not of the correct format.

Which is the best event to hook?

Should I hook an event on the SqlDataSource or on the Gridview?

Or should I Hook one of the page load events and do soemthing? (If so what should that be?)

Does anyone have any better solutions?

The Background is that I seem to be the target of a strange web crawler or bot, it goes through all the pages in my site, when it spots a link with a "ID" Parameter it repeats the request But replacing the value with a string like "http://www.filter-international.com/webservice/aro/medavuw/" Each "Attack" uses the same url, but next time the site is "Crawled" a differnt url is present. Does anyone have any info as to what someone is trying to achive by doing this?Start Free Trial
[+][-]04.29.2008 at 10:20AM PDT, ID: 21464247

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.30.2008 at 03:31AM PDT, ID: 21469364

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.30.2008 at 09:57AM PDT, ID: 21472488

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 11:37AM PDT, ID: 21509751

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Programming for ASP.NET, .NET Framework 2.0
Sign Up Now!
Solution Provided By: McExp
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906