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

A

Alan Silver

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.
 
Joined
Jul 20, 2007
Messages
1
Reaction score
0
Sir
Did you got any solution of your problem.If yes, please let me know.
Regards
Arshi



Alan Silver said:
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)
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top