how to redirect to same page

Discussion in 'ASP .Net' started by Carlos, Sep 24, 2009.

  1. Carlos

    Carlos Guest

    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.
     
    Carlos, Sep 24, 2009
    #1
    1. Advertising

  2. On Sep 24, 6:30 pm, "Carlos" <> wrote:
    > 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)
     
    Alexey Smirnov, Sep 25, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank Drebin
    Replies:
    0
    Views:
    771
    Frank Drebin
    Aug 25, 2003
  2. Bruce W..1
    Replies:
    3
    Views:
    13,339
    John Timney \(ASP.NET MVP\)
    Dec 10, 2003
  3. DotNetGruven
    Replies:
    3
    Views:
    15,282
  4. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,301
    Srowe1975
    Oct 15, 2008
  5. Sal
    Replies:
    1
    Views:
    807
Loading...

Share This Page