By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.