Parameter aus einem Querystring entfernen.

Gerade habe ich einen interessanten Artikel gefunden der zeigt, wie man einen Parameter aus der Querystringauflistung entfernen kann.

Public Sub RemoveQueryString(ByVal Req As HttpRequest, ByVal strKeyToDel As String, ByVal http_Context As HttpContext)
Dim nvc As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection(Req.QueryString)
Dim sPage As String = Req.ServerVariables("SERVER_NAME") & Req.ServerVariables("SCRIPT_NAME")
nvc.Remove(strKeyToDel)


Dim strNewURL As String = Req.Path
Dim sSeparator As String = "?"
Dim sKey As String
For Each sKey In nvc
If sKey <> Nothing Then
Dim sValues As String() = nvc.GetValues(sKey)
Dim sValue As String
For Each sValue In sValues
If sValue <> Nothing Then
strNewURL &= sSeparator
strNewURL &= sKey & "=" & sValue
sSeparator = "&"
End If
Next
End If
Next
If nvc.Keys.Count < 1 Then
strNewURL &= "?"
End If
http_Context.Current.RewritePath(strNewURL)
End Sub

Gefunden habe ich den Code unter http://www.codeproject.com

Kommentare (1) -

recombinant hormones
30.08.2006 12:58:23 #

recombinant hormones

Pingbacks and trackbacks (9)+

Kommentar schreiben