all groups > visual studio .net debugging > august 2007 >
You're in the

visual studio .net debugging

group:

Using a querystring when debugging a web application


Using a querystring when debugging a web application Nathan Sokalski
8/15/2007 10:39:45 AM
visual studio .net debugging:
Certain web pages throw an error when they do not have a querystring. This
is obviously no problem when the site is put live (just make the link to it
correct), but when debugging and the page is set as the Start Page, no
querystring is used. Is there a way to have the debugger start with a
querystring attached? (for example, by going to mypage.aspx?category=123
instead of just mypage.aspx) Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Re: Using a querystring when debugging a web application Alec MacLean
8/15/2007 6:47:26 PM
How about you add a little bit of graceful handling (defensive coding) to
the page so it knows what to do when no QS is present?

In the Page_Load event handler, add somhing along the lines of:

If Me.Request.QueryString.HasKeys Then
Dim iItemID As Integer
If Me.Request.QueryString.Count > 0 Then
'We have a querystring value, as yet unknown
Dim arrK() As String = Me.Request.QueryString.AllKeys
For i As Integer = 0 To arrK.Length - 1

'Do your processing...

Next
Else
'Handle the fact that the page has no querystring values...
Me.Response.Redirect("default.aspx")
End If
Else
'Handle the fact that the page has no querystring values...
Me.Response.Redirect("default.aspx")
End If


[quoted text, click to view]

Re: Using a querystring when debugging a web application Alec MacLean
8/16/2007 4:31:56 PM
You can add the QueryString programmatically using a modification of my
earlier post (see below).

Al

[quoted text, click to view]
<snip>

If Not Me.Request.QueryString.HasKeys Then
'Handle the fact that the page has no querystring values...
me.response.redirect(me.request.path & "?category=123")
End If


<snip>
[quoted text, click to view]

AddThis Social Bookmark Button