Skydda mot URL-injektion med TryParse

Har precis som Mads Kristensen märkt av att attacker med URL-injektioner har ökat det senaste.

På en sajt har jag fått in anrop som ser ut ungefär som här:

http://www.examplesite.com/product.aspx?categoryid=0 and user>0
http://www.examplesite.com/product.aspx?categoryid=0 ' and user>0 and ''='

URLerna är påhittade men på slutet av dem ser ni hur roboten lägger till extra strängar i parametern. Jag hade inte tänkt på att skydda mot detta och det blev error när sidan försökte konvertera parametern till en integer.

För att undervika fel kan man använda TryParse istället för Convert.ToInt32 (om man nu vart lika oförsiktig som jag från början).

int categoryId = -1;
Int32.TryParse(Request.QueryString["categoryid"], out categoryId);

Läs mer på MSDN eller i kommentarerna till ett inlägg hos CodeBetter.com.

Comments

From MSDN you easily get this information.

printer support number

good post.From MSDN you easily get this information.thank you. http://www.onlinepromotionuae.ae

Really a good work it is…! Thanks for sharing...

Epson Printer Support Number HP Printer Support Number

Thank you so much for sharing good information with us.

eCommerce Web Designing Company in Virginia

good posting........ Web Promotion Company in Delhi

Great Post. Thank you for sharing.. Printer has a great importance in professional fronts. What will happen if your HP printer stops working while printing some of your important documents? Well answer for it will be available at Hp Printer Support Number UK. Just call and correct errors in your printer by your own. Get in touch with Dell Printer Support Number UK, Lexmark Printer Support Number UK

Epson printer customer UK service to 0800-098-8569 support helpline, Epson support provides Epson customer, Epson support problem of Epson product to all type of technical support.

For acer pc & laptop, acer support uk tollfree 0800-098-8590 provide Acer Support, Acer Help Number, Acer Support Number, Acer technical support, Acer customer support, Acer customer service number, Acer Technical Support Phone Number, Acer Customer Support Number, Acer Helpline Number, Acer Technical Support Number, acer tech support all type of acer software problem.

Call us at UK Toll-Free 0800-014-8577 Acer Support, Acer laptop helpline, Acer Customer Service, Acer technical support, Acer laptop help, Acer technical support uk, Acer laptop support, Acer helpline or any Acer tech support for any problem in Acer UK.

Call us at UK Toll-Free 0800-014-8577 Acer Support, Acer Customer Service, Acer helpline or any Acer tech support for any problem in Acer UK.

Hii, yes, That is great idea for longtime. i'm agreed with you. We are offering a new and latest Acer Support Service.Call us at UK Toll-Free 0800-014-8577 Acer Support, Acer Technical Support, Acer Customer Service, Acer helpline or any Acer tech support for any problem in Acer UK.

Dell printer Support Advice UK, Dell printer Product, Dell printer Refill, Dell printer cartage, Dell printer Service, You Need All in UK, Technical Support UK 0800-098-8569

Hii, yes, That is great idea for longtime. i'm agreed with you. We are offering a new and latest Epson Printer Support.Call @0800-090-3288 for Epson Support, Epson Printer Help, Epson Support Number, Epson Technical Support, Epson Customer Service, Epson Printer Support, Epson Helpline.

Today I learned a lot from your website. thank you We are offering a new and latest Epson Printer Support.Call @0800-090-3288 for Epson Support, Epson Printer Helpline UK, Epson printer Support Number, Epson Printer Customer Support, Epson Printer Customer Service, Epson Printer Technical Support, Epson Printer Help Number.

It's a very nice post,I have learnt a lot by your post Best Spy Mobile Phone Software in Delhi India for Android, Blackberry, Windows, iPhone Smartphone Buy Online Cell Phone Monitoring Spy Mobile App Shop Now

Spy Mobile Phone Software in India

In the list of antivirus the name which comes in the top is of Panda but still it shows many technical errors during its use. If you are also amongst those who faces tech issues while using panda then calling at +44-800-098-8371 Panda Support Number UK will help you in resolving all such tech issues in few minutes.

Getting in touch with technicians to solve out all HP printer issues is easy as you can get it by calling tech experts at HP Printer Help Number UK. The technicians of this help desk are well trained in solving out all such issues and that to be in shortest ways. HP Printer Helpline Number UK

Today I learned a lot from your website. thank you.

Microsoft Support Number

It‘s actually a nice and useful piece of information. We Provide the best technical support for Antivirus. ( Avast Support Number UK & Avast Customer Care Number UK )

this is outstanding and great post! i really like it. thank you so much.

Brother printer support number

brother Support

It's a very nice post,I apprecaite your work,thanks for share Asus Support Asus Helpline

I have got a lotof info that you have share,Thanks for share such aa good piece of content with us Epson Helpline

Epson Support Number

I am glad to read your blog,Really amazing post,Thanks for share

Dell Support Number

Dell Support

Superb Idea.

Hotmail Support

I am so glad to read your blog post,Thanks for share such a good piece of content with us Gmail Support Number Yahoo Support Number

Wow,Great post,Keep it up,I wants you to look my site link If there are some issue then tell me,Thanks Norton Support Norton Customer Support

This is outstanding and great post! i really like it.thank you so much. Brother printer support

If you need technical support to resolve problems related with the use of copy and scan feature in your all in one Brother Printer, then you must contact our technicians at 0808-238-7544 Brother Printer Phone UK and they will always happy to serve you quick solution.

If you are facing any Window Problem while using your computer then you can get instant Window Support 24*7 from us.

Windows Customer Support

Hi, Thanks for the sharing nice posting with us. i am really impressed. We are offering a new and latest Windows Customer Support

Please fill out all the fields.

*
*