Zulfi Tapia
Zulfi Tapia

Reputation: 526

Get value from string formed as URL in ASP.NET

Ok, I have a string of the form

string temp = "http://www.example.com?file=666111&submitter=Betty&origin=Office&telNo=05555";

what I need to do is extract the value of the file variable in order to use it. If this was the referrer url I could've done Request.QueryString and got it but the problem is that I have it as a string variable.

I could try to do substring and get the value but I was hoping there was a cleaner way to do this?

Upvotes: 0

Views: 1178

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30661

Perhaps you can use the HttpUtility.ParseQueryString method. It returns a NameValueCollection with all parameters.

Upvotes: 7

Related Questions