How to extract variable and its value from URL

  • Thread starter Thread starter Jozef Jarosciak
  • Start date Start date
This variable getting... do you want to do this to a URL, or from within a
page that has been requested with those variables?

If it is the 2nd, take a look at the Response class which you can easily
query with...

int varA,varB;
varA = Response["a"];
varB = Response["b"];

Brendan
 
Jozef,

You wouldn't even need a regular expression, you can just parse it apart
on the equals sign and the ampersand (but a regular expression would work
fine as well).

Pass the URL to the constructor of the Uri class, and then use the Query
property to get the query string. Drop the first character (it is always
the question mark), and the rest should be easy to parse. The only thing
you have to worry about at that point is the encoding which is a simple
matter of fixing).

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top