Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Server.Transfer and URL Rewriting

Hello.

I am using the Server.Transfer method inside my asp.net code so that I could use the Context.Items collection. With Response.Redirect I would not have access to the Context.Items collection. The problem is I have a custom control that displays the navigation links to the page and it parses the current URL to get the page file name. It has a switch statement to decide which navigation images to display depending upon what page the user is on. However, after a server.transfer the url is still set to the old one. I am wondering if I could somehow rewrite the url with the use of server.transfer or if I could rewrite the url instead of using server.transfer and still have access to the context.items collection? If somebody knows how I could solve this issue, I would really appreciate it.

thanks,
Monarltee
[847 byte] By [monarltee] at [2007-11-11 10:12:52]
# 1 Re: Server.Transfer and URL Rewriting
I don't know of any way to use URL rewriting with Server.Transfer.

Why not simply use Session or ViewState (instead of Context.Items) with Response.Redirect? That would probably be my first choice. Second choice would be to use some mechanism other than parsing the URL to drive navigation; why not store the page name in the Context.Items collection?
Phil Weber at 2007-11-11 23:12:05 >
# 2 Re: Server.Transfer and URL Rewriting
Hi Phil. Thank you for your reply. Is there any way that I could get the page file name besides parsing the URL? I though there must be some way to get filename.aspx from the page without going through the URL.

thanks again,
Monarltee
monarltee at 2007-11-11 23:13:00 >
# 3 Re: Server.Transfer and URL Rewriting
How are you getting the URL now? You might try Request.Path or Request.ServerVariables ( http://www.4guysfromrolla.com/webtech/092298-3.shtml).
Phil Weber at 2007-11-11 23:14:04 >
# 4 Re: Server.Transfer and URL Rewriting
Hi Phil. I am getting the URL right now by using Page.Request.RawUrl .

If the page name was Checkout.aspx. If I use Page.GetType.ToString, I will get this result:

ASP.checkout_aspx

I was wondering if there was another way besides Page.GetType that will return "Checkout.aspx" instead of "ASP.checkout_aspx"

thank you so much,
Monarltee
monarltee at 2007-11-11 23:15:09 >