how to redirect to same page

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.
 
A

Alexey Smirnov

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top