467,171 Members | 1,258 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,171 developers. It's quick & easy.

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

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)
Dec 19 '05 #1
  • viewed: 2168
Share:
1 Reply
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)
Dec 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by PaulThomas | last post: by
3 posts views Thread by Bishoy George | last post: by
3 posts views Thread by Maziar Aflatoun | last post: by
1 post views Thread by treelife | last post: by
4 posts views Thread by Stan Canepa | last post: by
4 posts views Thread by =?Utf-8?B?SlA=?= | last post: by
9 posts views Thread by Jonathan Wood | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.