1

I am getting the current URL with:

   string url = HttpContext.Current.Request.Url.AbsoluteUri;
//url = blahblahblah.aspx?NUMBER=8798494651&FULLNAME=Ronald

After this, I want to use url.Split() to obtain the value after both equals signs. This would normally be straight forward but as you can see the first value has an obvious end character of '&' while the other does not. Furthermore, the FULLNAME value can always be different.

I have seen other Regex parsing questions/answers on here but of course they are all for specific cases.

Thanks in advance.

Jonathan Scialpi
  • 771
  • 2
  • 11
  • 32

1 Answers1

4

Try this

var uri = new Uri("blahblahblah.aspx?NUMBER=8798494651&FULLNAME=Ronald");
var query = HttpUtility.ParseQueryString(uri.Query);

var var1 = query.Get("NUMBER");
var var2 = query.Get("FULLNAME");
10K35H 5H4KY4
  • 1,496
  • 5
  • 19
  • 41