Click here to Skip to main content
14,092,869 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

16.8K views
2 bookmarked
Posted 22 Dec 2011
Licenced CPOL

Treat a plain string as URL and fetch query string values

, 22 Dec 2011
Rate this:
Please Sign up or sign in to vote.
A simpler way to parse a URL address string in VB.NET as URL itself and fetch query string values
Consider the below code statement:

Dim strURLAddress As String
strURLAddress = "http://www.google.co.in/search?sourceid=chrome&ie=UTF-8&q=CodeProject"

Let's say the job is to fetch the query string value for "ie" in the above URL Address.

The plain and simple way is to use indexes, substring and get dirty with the string functions.

Here's a much better alternative:

HttpUtility.ParseQueryString(strURLAddress)("ie")


ParseQueryString is a method of HttpUtility class under System.Web namespace.

It simply parses a query string into a NameValueCollection using UTF8 encoding.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jyothikarthik_N
Technical Lead
United States United States
Engineer.

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 1 Pin
PetePuma3-Oct-12 15:22
memberPetePuma3-Oct-12 15:22 
NewsRe: My vote of 1 Pin
Jyothikarthik_N6-Oct-12 12:30
memberJyothikarthik_N6-Oct-12 12:30 
GeneralJyothikarthik_N,thank you for your helping.I am coding proje... Pin
tdyso_zmh27-Dec-11 23:18
membertdyso_zmh27-Dec-11 23:18 
GeneralI tried it but failed.There is no "HttpUtility" in "System.... Pin
tdyso_zmh22-Dec-11 21:46
membertdyso_zmh22-Dec-11 21:46 
GeneralRe: tdyso, Try explicitly "Add Reference" to System.Web Namespa... Pin
Jyothikarthik_N22-Dec-11 22:15
memberJyothikarthik_N22-Dec-11 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190518.1 | Last Updated 22 Dec 2011
Article Copyright 2011 by Jyothikarthik_N
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid