How can I get the URL and Querystring? vb.net

To get the current query string you would simply do something like the following:

Dim query as String = Request.QueryString("d")

This will assign the value of the "d" querystring to the string variable "query". Note that all query string values are strings, so if you're passing numbers around, you'll need to "cast" or convert those string values to numerics (be careful of exceptions when casting, though). For example:

Dim query as String = Request.QueryString("d")
Dim iquery as Integer = CType(query, Integer)

The QueryString property of the Request object is a collection of name/value key pairs. Specifically, it's of type System.Collections.Specialized.NameValueCollection, and you can iterate through each of the name/value pairs as so:

Dim coll As System.Collections.Specialized.NameValueCollection = Request.QueryString
Dim value As String
For Each key As String In coll.AllKeys
   value = coll(key)
Next

Using either of these mechanisms (or something very similar) should enable you to construct a string variable which contains the full url (page and querystrings) that you wish to navigate to.


Try this:

so.Cpage = "ContractChange.aspx?" & Request.RawUrl.Split("?")(1)

In VB.Net you can do it with the following.

Dim id As String = Request.Params("RequestId")

If you want to process this in as an integer, you can do the following:

Dim id As Integer

If Integer.TryParse(Request.Params("RequestId"), id) Then
   DoProcessingStuff()
End If