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

Server.Transfer vs Response.Redirect

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Instead of using the .../. Use the ~ to say go to the root directory.

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

--
TDAVISJR
aka - Tampa.NET Koder
"Calvin KD" <Ca******@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
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

Nov 19 '05 #2

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

Calvin KD wrote:
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

Nov 19 '05 #3

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

"TDAVISJR" wrote:
Instead of using the .../. Use the ~ to say go to the root directory.

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

--
TDAVISJR
aka - Tampa.NET Koder
"Calvin KD" <Ca******@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
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


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.