server.transfer and URL address - confused

B

Bob H

Hi,

I'm aware of the different ways to pass variables between ASP.Net pages. For
pages that need to pass a variable, we're using the server.transfer method.
For others, we're using repsonse.redirect. My understanding was that the
server.transfer method doesn't update the URL address bar. However, I've a
situation that I'm a bit confused about and would appreciate any advice on
why the following is occuring (i.e. why I'm obviously missing something in
all this):

1) Move from Page1.aspx to Page2.aspx via a response.redirect. URL address
bar changes to Page2.aspx.
2) Move from Page2.aspx to Page3.aspx via a server.transfer. URL address bar
stays with Page2.aspx.
3) Move from Page3.aspx to Page4.aspx via a server.transfer. URL address bar
changes to Page3.aspx.

...During the move in point 3, I would have thought that the URL address bar
would stay with Page2.aspx. Is the above the correct behaviour, or is there
something amiss?

Thanks for any advice on this.

Cheers

Bob
 
M

Martin Dechev

Hi, Bob,

Note that between step 2 and 3 there is a post to the server to Page3.aspx.
That's why you see Page3.aspx in the address bar.

Greetings
Martin
 
P

Patrice Scribe

Looks weird, only a new client side request for page3.aspx should be able to
change the URL. Is there any intermediate steps or it is done all in one
flow (any postback in beetween ?)

You could easily try to repro this behaviour with 3 empty pages...

As a side note, I would use Server.Transfer only for processing only pages
(ie the user shouldn't care to be on another page than the one he sees in
his address bar, other said I would not use it for navigation purpose).

Patrice
 
B

Bob H

Thanks for the replies.

I setup 4 blank pages with the same navigation:
- Page1 to Page2 with response.redirect
- Page2 to Page3 to Page4 with server.transfer

Same thing happens. I had forgot about the postback to Page3 (hence the URL
change to Page3 when navigating to Page4)...although I had thought that only
client side could update the address bar (?).

I suppose what I'm after is to be able to navigate to another page, pass the
variables (in a 'hidden' format) and have the URL bar updated (without the
issues of querystring & sessions). Is it possible to server.transfer to an
intermediate page (e.g. Page2.5), before redirecting to Page3 (with
variables and URL bar intact)??...although doesn't this just pose the same
problem of how to get variables from 2.5 to 3?

cheers

Bob
 
P

Patrice Scribe

The postback means the data in your form are submitted by the browser to a
page. This *is* a client side request and it updates then the URL.

If you need to let the user know he is on a new page, use Response.Redirect
(and its additional small hit)
If this is a processing only page use Server.Transfer.

Patrice


--
 

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

Top