Сложно проверять все. Мне просто некогда очень сейчас. Хотелось побыстрее. Но я в принципе уже наковырял на скорую руку такое
Public Shared Function ParseURL(ByVal Key1 As String, ByVal Value1 As String) As String
Dim Insert As Boolean = False
Dim PRM As New Collections.Specialized.NameValueCollection
For Each K As String In HttpContext.Current.Request.QueryString.AllKeys
If K = Key1 Then
PRM.Add(K, Value1)
Insert = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
Next
If Not Insert Then PRM.Add(Key1, Value1)
''
Dim NewUrl As New System.Text.StringBuilder(HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.Url.AbsolutePath)
If PRM.Count = 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
ElseIf PRM.Count > 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
For i As Integer = 1 To PRM.Count - 1
NewUrl.Append("&" & PRM.Keys(i) & "=" & PRM.Item(i))
Next
End If
Return NewUrl.ToString
End Function
Public Shared Function ParseURL(ByVal Key1 As String, ByVal Value1 As String, ByVal Key2 As String, ByVal Value2 As String) As String
Dim Insert() As Boolean = {False, False}
Dim PRM As New Collections.Specialized.NameValueCollection
For Each K As String In HttpContext.Current.Request.QueryString.AllKeys
If K = Key1 Then
PRM.Add(K, Value1)
Insert(0) = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
If K = Key2 Then
PRM.Add(K, Value2)
Insert(1) = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
Next
If Not Insert(0) Then PRM.Add(Key1, Value1)
If Not Insert(1) Then PRM.Add(Key2, Value2)
''
Dim NewUrl As New System.Text.StringBuilder(HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.Url.AbsolutePath)
If PRM.Count = 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
ElseIf PRM.Count > 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
For i As Integer = 1 To PRM.Count - 1
NewUrl.Append("&" & PRM.Keys(i) & "=" & PRM.Item(i))
Next
End If
Return NewUrl.ToString
End Function
Public Shared Function ParseURL(ByVal Key1 As String, ByVal Value1 As String, ByVal Key2 As String, ByVal Value2 As String, ByVal Key3 As String, ByVal Value3 As String) As String
Dim Insert() As Boolean = {False, False, False}
Dim PRM As New Collections.Specialized.NameValueCollection
For Each K As String In HttpContext.Current.Request.QueryString.AllKeys
If K = Key1 Then
PRM.Add(K, Value1)
Insert(0) = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
If K = Key2 Then
PRM.Add(K, Value2)
Insert(1) = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
If K = Key3 Then
PRM.Add(K, Value3)
Insert(2) = True
Else
PRM.Add(K, HttpContext.Current.Request.QueryString(K))
End If
Next
If Not Insert(0) Then PRM.Add(Key1, Value1)
If Not Insert(1) Then PRM.Add(Key2, Value2)
If Not Insert(2) Then PRM.Add(Key2, Value3)
''
Dim NewUrl As New System.Text.StringBuilder(HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.Url.AbsolutePath)
If PRM.Count = 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
ElseIf PRM.Count > 1 Then
NewUrl.Append("?" & PRM.Keys(0) & "=" & PRM.Item(0))
For i As Integer = 1 To PRM.Count - 1
NewUrl.Append("&" & PRM.Keys(i) & "=" & PRM.Item(i))
Next
End If
Return NewUrl.ToString
End Function
Ну и так далее. Пользоваться так
Response.Redirect(ParseURL("SID", Session("SemesterID")))
или
Response.Redirect(ParseURL("MainID", Session("MainCategoryID")),"SubID", Session("SubCategoryID"))
Вроде работает. Ну все-провсе почти час наверное ушел. Просто некогда было. Думал что-то готовое есть.