Grab $_GET like in PHP but in Visual Basic?

2020-05-07 04:52发布

问题:

I have a web browser called WebBrowser1 and I want to be able to detect the $_GET like i would be able to in PHP and place it in a Textlabel

Like if the url was:

www.example.com/page.php?myget=true

Is it possible to Visual Basic to grab what ever is in 'myget'. I'm a bit new at the this so please let me know.

回答1:

You probably want:

Request.QueryString("myget") 

for properties on the querystring.

Request.Form() would get you posted params

and Request.Params() will get params from both.



回答2:

This is assuming you are running a webforms VB.net application.

First you'll need to add a reference to System.Web

Then use the following code to read the querystring from the browser uri and parse it into a collection of name value pairs. If you don't want to include System.Web you could write your own code to do it based on the value of WebBrowser1.Uri.Query

Dim queryString As String = webBrowser1.Url.Query
Dim queryStringValues As NameValueCollection = HttpUtility.ParseQueryString(queryString)
Dim lolValue As String = queryStringValues("lol")