.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

query string

Posted By: yogesh tiwari     Posted Date: November 22, 2011    Points:5   Category :ASP.Net
Dear sir

need help trying to verify that my querysting is valid. I'm trying to ensure that if the user manipulates the querysting value to something invalid, that I catch it and send them to my error page.

Example, I have a querystring parameter named "comID" how do I check to make sure the user didn't accidentally change it to "commID" or something else invalid? Right now, if the user mispells the querystring variable or deletes it alltogether they get an unfriendly asp error page "Object reference not set to an instance of an object." I want to catch this and display my error page before getting to the asp error page. If they simply enter a value that is invalid ?comID=5 and say 5 doesn't exist, I have a try catch block that informs them that it is invalid. I'm only concerned about the querystring being spelled correctly and it must be present.

communityInfo.aspx?comID=1 - good
communityInfo.aspx - error
communityInfo.aspx?commmIDE - error

My page works fine as long as the user doesn't manually change the querystring parameter but I still want to verify the name of the parameter, and if it equals "comID" then proceed as normal. If the querystring does not exist or is mispelled, I want to direct the user to my error page. Please help :)

By-the-way, I am programming is VB not C#. So if you could please respond with VB solutions I would appreciate it. Thanks in advance.

Author: Faizal             
Posted Date: December 02, 2011     Points: 20   


Yuu can check the querystring is null or not

for eg.

if(Request.QueryString["comID"] !=null)
//your logic

Author: hirecrishecom             
Posted Date: December 06, 2011     Points: 20   

on page load write this code

if(Request.QueryString["comID"] !=null)
//your logic

[url=http://www.axistechnolabs.com/programmers/asp-dotnet-programmers.aspx]hire asp.net developers[/url] , [url=http://www.axistechnolabs.co

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend