how to redirect to same page

  • Thread starter Thread starter Carlos
  • Start date Start date
C

Carlos

Hi all,

I have a page that when loads queries a parameter
that contains the URL where it came from. It also has
a button that when clicked, performs a DB operation and
redirects to the same page to check if there are more records
pending.

The problem is that when there are no more records pending,
I want to go back to the original URL. But when the postback occurs
in the button the page name gets appended to the URL forming an invalid
address.

If for example, it starts browsing at
http://www.mysite.com/mypage.aspx?ourl=http://www.myothersite.com


appends
http://www.mysite.com/mypage.aspx/mypage.aspx?orurl=http://www.myothesite.com
which is invalid. hat would be the best way to do this?

I am currently using server.transfer("#")

Thanks,

Carlos.
 
Hi all,

 I have a page that when loads queries a parameter
that contains the URL where it came from. It also has
a button that when clicked, performs a DB operation and
redirects to the same page to check if there are more records
pending.

The problem is that when there are no more records pending,
I want to go back to the original URL. But when the postback occurs
in the button the page name gets appended to the URL forming an invalid
address.

If for example, it starts browsing athttp://www.mysite.com/mypage.aspx?ourl=http://www.myothersite.com

appendshttp://www.mysite.com/mypage.aspx/mypage.aspx?orurl=http://www.myothe...
which is invalid. hat would be the best way to do this?

I am currently using server.transfer("#")

Thanks,

   Carlos.

Hi Carlos,

I think if you skip server.transfer("#") it will load you the same
page.

In case you need to redirect, you could use something like...

string qs = "";

foreach (string key in Request.QueryString.Keys)
{
qs += key + "=" + Request.QueryString[key] + "&";
}

server.transfer("mypage.aspx?"+qs)
 
Back
Top