Response.Redirect

J

Jennifer

Help! I'm confused. I had a web app written in ASP, version 2001
with VB as the code behind. I upgraded to 2005.

I have various places where there are links to another page. As such,
I have code using Response.Redirect.

So in the 2001 version I would specify the main directory where the
web pages resided. For example, I have a folder called DSR. I would
use Response.Redirect("DSR/Main.aspx")

But in the 2005 version, Visual Studio didn't like that. When running
the code, the link would end up looking like:
http://localhost:2877/DSR/Main.aspx

So I went through and took out all references to DSR/.

Okay, so I published it to the development server and now I'm getting
the error message that the resource can't be found. I look at the
address bar and I see:
http://dvwww01/Main.aspx instead of http://dvwww01/DSR/Main.aspx

So I go back through all my code adding in the DSR again.

Guess what the link looks like now?

http://dvwww01/DSR/dsr/Main.aspx

It's like I'm damned if I do and damned if I don't. Not to mention
frustrating as all get out. I won't even go to all the other upgrade
issues. :) Anyway, does anyone have suggestions?

Jennifer
 
G

Göran Andersson

Jennifer said:
Help! I'm confused. I had a web app written in ASP, version 2001
with VB as the code behind. I upgraded to 2005.

I have various places where there are links to another page. As such,
I have code using Response.Redirect.

So in the 2001 version I would specify the main directory where the
web pages resided. For example, I have a folder called DSR. I would
use Response.Redirect("DSR/Main.aspx")

But in the 2005 version, Visual Studio didn't like that. When running
the code, the link would end up looking like:
http://localhost:2877/DSR/Main.aspx

So I went through and took out all references to DSR/.

Okay, so I published it to the development server and now I'm getting
the error message that the resource can't be found. I look at the
address bar and I see:
http://dvwww01/Main.aspx instead of http://dvwww01/DSR/Main.aspx

So I go back through all my code adding in the DSR again.

Guess what the link looks like now?

http://dvwww01/DSR/dsr/Main.aspx

It's like I'm damned if I do and damned if I don't. Not to mention
frustrating as all get out. I won't even go to all the other upgrade
issues. :) Anyway, does anyone have suggestions?

Jennifer

Use ~ in the URL to specify the root folder:

Response.Redirect("~/Main.aspx")

This works regardless if the root folder is a web site or a virtual
folder, so it will work both in development and live.
 
J

Jennifer

Use ~ in the URL to specify the root folder:

Response.Redirect("~/Main.aspx")

This works regardless if the root folder is a web site or a virtual
folder, so it will work both in development and live.

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Thank you for sharing that with me. I really appreciate it! Where do
you learn this kind of thing? It certainly isn't in the help files.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top