Server.Transfer vs Response.Redirect

G

Guest

Hi everyone,
I don't know if there's anyone out there is having the same problem. My
DotNet 1.1 version uses FormsAuthentication.RedirectFromLoginPage() method to
take user from the Login page to the Welcome page. My folder structure is as
follows:
Root Dir
bin
images
secure
Welcome
Folder1
Page1
Folder 2
Page 2
login
stylesheet
web.config

To navigate to other pages within the application, Server.Transfer() method
seems to lose its node's coordinates relative to the whole tree structure.
For example, the Welcome page references the stylesheet as ../stylesheet.css
and Page1's reference is ../../stylesheet.css. When I used Server.Transfer
method to go to Page1 from Welcome page, Page1 cannot find the stylesheet.
However, if I replace Server.Transfer with Response.Redirect, all relative
references are ok.
Can someone shed some light on this problem of mine and tell me what i have
done wrong?
Any help is greatly appreciated.
KD
 
T

TDAVISJR

Instead of using the .../. Use the ~ to say go to the root directory.

Server.Transfer("~/secure/Welcome.aspx");
 
D

dave bray

When you use server transfer, the url doesn't change - so your page
thinks it is the first page

from default.asp;

server.transfer "another-folder/anotherfile.asp"


request.servervariables( "script_name" ) will return "default.asp" from
both pages .. thats by design
 
G

Guest

Thanks TDAVISJR. I tried replacing the .. with ~/level1/level2/page1.aspx but
it still doesn't work. I found out something quite peculiar, may be it's by
design? What I have found was, with the Server.Transfer method, only the
parent-child relationship can be maintained. That is, it's OK to navigate
from the Root (parent) to the next level (child) and back, then the root
remains the same. However, if you go from the Root to Level1, then to Level2
as in:
Root
Level1
Page1.aspx
Level2
Page2.aspx
To Page1.aspx, its virtual root now becomes Level1 (instead of the actual
Root). As a consequence, if you navigate from Page2.aspx back to a page under
the actual Root directory, all references are now out of synch. It's quite
bizarre and frustrating to say the least.
As a consequence, I can't use the HttpContext.Current.Items collection to
maintain my Session variables (as it only work with Server.Transfer, not
Response.Redirect).
Can someone prove me wrong here? I'm more than happy if this isn't the case.

KD
 

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,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top