Help please - Context.RewritePath redirects to home page, Response.Redirect works fine

Discussion in 'ASP .Net' started by Alan Silver, Dec 19, 2005.

  1. Alan Silver

    Alan Silver Guest

    Hello,

    I have a page where site owners can see orders placed on their site. The
    path to this page is /dap/order.aspx, but for security reasons (as they
    will end up printing these pages and sending them to customers) I am
    trying to rewrite the path so the URL shown in the page footer is not a
    real one.

    I want to use an URL like http://www.domain.com/order123.aspx and have
    it rewritten to http://www.domain.com/dap/order.aspx?orderid=123

    I have the following in the global.asax...

    void Application_BeginRequest(Object sender , EventArgs e) {
    string strPath = Request.Path.ToLower();
    if (strPath.StartsWith("/order")) {
    strPath = strPath.Substring(6);
    strPath = strPath.Replace(".aspx", "");
    Context.RewritePath("/dap/order.aspx?orderid=" + strPath);
    }
    }

    When I try to access http://www.domain.com/order123.aspx, I get
    redirected to http://www.domain.com/ instead of the /dap/order.aspx
    page.

    If I change the Context.RewritePath to Response.Redirect, then the
    order.aspx page loads fine, but obviously shows the real URL instead of
    the fake one.

    Anyone any idea why this is happening? I had this working some time ago
    and haven't looked at it recently. I revisited this page as I have
    loaded version 2.0 of the framework, and was converting these pages to
    use master pages. I don't know if the new version of the framework works
    differently, or if it's configuring the /dap folder as a separate
    application (which was around the same time) has done it.

    Any help appreciated.

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Dec 19, 2005
    #1
    1. Advertising

  2. Alan Silver

    Alan Silver Guest

    Anyone any idea about this? I'm really desperate here. TIA

    >Hello,
    >
    >I have a page where site owners can see orders placed on their site. The
    >path to this page is /dap/order.aspx, but for security reasons (as they
    >will end up printing these pages and sending them to customers) I am
    >trying to rewrite the path so the URL shown in the page footer is not a
    >real one.
    >
    >I want to use an URL like http://www.domain.com/order123.aspx and have
    >it rewritten to http://www.domain.com/dap/order.aspx?orderid=123
    >
    >I have the following in the global.asax...
    >
    >void Application_BeginRequest(Object sender , EventArgs e) {
    > string strPath = Request.Path.ToLower();
    > if (strPath.StartsWith("/order")) {
    > strPath = strPath.Substring(6);
    > strPath = strPath.Replace(".aspx", "");
    > Context.RewritePath("/dap/order.aspx?orderid=" + strPath);
    > }
    >}
    >
    >When I try to access http://www.domain.com/order123.aspx, I get
    >redirected to http://www.domain.com/ instead of the /dap/order.aspx
    >page.
    >
    >If I change the Context.RewritePath to Response.Redirect, then the
    >order.aspx page loads fine, but obviously shows the real URL instead of
    >the fake one.
    >
    >Anyone any idea why this is happening? I had this working some time ago
    >and haven't looked at it recently. I revisited this page as I have
    >loaded version 2.0 of the framework, and was converting these pages to
    >use master pages. I don't know if the new version of the framework works
    >differently, or if it's configuring the /dap folder as a separate
    >application (which was around the same time) has done it.
    >
    >Any help appreciated.
    >


    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Dec 21, 2005
    #2
    1. Advertising

  3. Alan Silver

    arshi

    Joined:
    Jul 20, 2007
    Messages:
    1
    Sir
    Did you got any solution of your problem.If yes, please let me know.
    Regards
    Arshi



    arshi, Jul 20, 2007
    #3
    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. Matt Howeson
    Replies:
    1
    Views:
    4,038
    gbrad
    May 10, 2006
  2. Ayende Rahien

    Form action and Context.RewritePath

    Ayende Rahien, Jan 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    564
    Ayende Rahien
    Jan 3, 2004
  3. Flip Rayner
    Replies:
    1
    Views:
    639
    bruce barker
    Jan 23, 2007
  4. Sal
    Replies:
    1
    Views:
    381
  5. Matt
    Replies:
    0
    Views:
    107
Loading...

Share This Page