473,287 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Response.Redirect vs. Server.Transfer - using ~ operator

I apologize in advance for the length of this post. I wanted to get as
much detail as possible in here.

We have 1 web app that contains the functionality to do some single
sign-on logic. The flow is

1. Welcome page
2. Login Page (where the SSO actually occurs)
3. Welcome page
4. Default page

We have a separate web app that also needs to use the SSO
functionality, so rather than duplicating it, it redirects to the
pages within the first app. So the workflow for the second app
becomes

1. Welcome page (App #2)
2. Login Page (App #1 - where the SSO actually occurs, but this time
passing a return URL)
3. Welcome Page (App #1 - still passing the Return URL)
4. Return URL (App #2)

Everything is fine with the first app by itself. Essentially, the last
line in that page is

Response.Redirect("~/Login/Welcome.aspx");

and this works fine. In the second scenario, since the return URL is
being passed, the line becomes

Response.Redirect("~/Login/Welcome.aspx?ReturnURL=http://App2/
default.aspx");

This generates an application error with a message of

"/App1/Login/~/Login/Welcome.aspx?ReturnURL=http://App2/default.aspx"
cannot be found.

So it looks like it sees the '~' as a literal part of the path and
does not actually resolve it correctly in the second scenario. It
looks like it assumes that it needs to append the relative path to the
front of the URL passed to Response.Redirect. If we use
Server.Transfer instead, it works just fine. Does anyone know why this
is the case?
Jun 27 '08 #1
3 3499
I think the problem is that you do not encode URL correctly.
Must be something like
Response.Redirect("~/Login/Welcome.aspx?ReturnURL=" +
Server.UrlEncode(http://App2/default.aspx") );

George.
<ja************@gmail.comwrote in message
news:e1**********************************@26g2000h sk.googlegroups.com...
>I apologize in advance for the length of this post. I wanted to get as
much detail as possible in here.

We have 1 web app that contains the functionality to do some single
sign-on logic. The flow is

1. Welcome page
2. Login Page (where the SSO actually occurs)
3. Welcome page
4. Default page

We have a separate web app that also needs to use the SSO
functionality, so rather than duplicating it, it redirects to the
pages within the first app. So the workflow for the second app
becomes

1. Welcome page (App #2)
2. Login Page (App #1 - where the SSO actually occurs, but this time
passing a return URL)
3. Welcome Page (App #1 - still passing the Return URL)
4. Return URL (App #2)

Everything is fine with the first app by itself. Essentially, the last
line in that page is

Response.Redirect("~/Login/Welcome.aspx");

and this works fine. In the second scenario, since the return URL is
being passed, the line becomes

Response.Redirect("~/Login/Welcome.aspx?ReturnURL=http://App2/
default.aspx");

This generates an application error with a message of

"/App1/Login/~/Login/Welcome.aspx?ReturnURL=http://App2/default.aspx"
cannot be found.

So it looks like it sees the '~' as a literal part of the path and
does not actually resolve it correctly in the second scenario. It
looks like it assumes that it needs to append the relative path to the
front of the URL passed to Response.Redirect. If we use
Server.Transfer instead, it works just fine. Does anyone know why this
is the case?

Jun 27 '08 #2
Response.Redirect actually goes back to the browser and tells the *browser*
to request the new "page". Server.Transfer all happens on the server, and
the new page is simply sent out to the browser, with no new round trip to
the browser at all.
Peter
<ja************@gmail.comwrote in message
news:e1**********************************@26g2000h sk.googlegroups.com...
>I apologize in advance for the length of this post. I wanted to get as
much detail as possible in here.

We have 1 web app that contains the functionality to do some single
sign-on logic. The flow is

1. Welcome page
2. Login Page (where the SSO actually occurs)
3. Welcome page
4. Default page

We have a separate web app that also needs to use the SSO
functionality, so rather than duplicating it, it redirects to the
pages within the first app. So the workflow for the second app
becomes

1. Welcome page (App #2)
2. Login Page (App #1 - where the SSO actually occurs, but this time
passing a return URL)
3. Welcome Page (App #1 - still passing the Return URL)
4. Return URL (App #2)

Everything is fine with the first app by itself. Essentially, the last
line in that page is

Response.Redirect("~/Login/Welcome.aspx");

and this works fine. In the second scenario, since the return URL is
being passed, the line becomes

Response.Redirect("~/Login/Welcome.aspx?ReturnURL=http://App2/
default.aspx");

This generates an application error with a message of

"/App1/Login/~/Login/Welcome.aspx?ReturnURL=http://App2/default.aspx"
cannot be found.

So it looks like it sees the '~' as a literal part of the path and
does not actually resolve it correctly in the second scenario. It
looks like it assumes that it needs to append the relative path to the
front of the URL passed to Response.Redirect. If we use
Server.Transfer instead, it works just fine. Does anyone know why this
is the case?
Jun 27 '08 #3
I want to add....
Do not use Server.Transfer if you do not know all implications...
Response.Redirect and Server.Transfer are not interchangeable.

When using Server.Transfer ASP.NET is actually using new .aspx page (the one
you transferred to).
But the browser still thinks that you are at old .asp page and POST back
will go to old .aspx page......
Hence a lot of problems.....
George.
"Peter Bromberg [C# MVP]" <pb*******@nospammin.yahoo.comwrote in message
news:1A**********************************@microsof t.com...
Response.Redirect actually goes back to the browser and tells the
*browser* to request the new "page". Server.Transfer all happens on the
server, and the new page is simply sent out to the browser, with no new
round trip to the browser at all.
Peter
<ja************@gmail.comwrote in message
news:e1**********************************@26g2000h sk.googlegroups.com...
>>I apologize in advance for the length of this post. I wanted to get as
much detail as possible in here.

We have 1 web app that contains the functionality to do some single
sign-on logic. The flow is

1. Welcome page
2. Login Page (where the SSO actually occurs)
3. Welcome page
4. Default page

We have a separate web app that also needs to use the SSO
functionality, so rather than duplicating it, it redirects to the
pages within the first app. So the workflow for the second app
becomes

1. Welcome page (App #2)
2. Login Page (App #1 - where the SSO actually occurs, but this time
passing a return URL)
3. Welcome Page (App #1 - still passing the Return URL)
4. Return URL (App #2)

Everything is fine with the first app by itself. Essentially, the last
line in that page is

Response.Redirect("~/Login/Welcome.aspx");

and this works fine. In the second scenario, since the return URL is
being passed, the line becomes

Response.Redirect("~/Login/Welcome.aspx?ReturnURL=http://App2/
default.aspx");

This generates an application error with a message of

"/App1/Login/~/Login/Welcome.aspx?ReturnURL=http://App2/default.aspx"
cannot be found.

So it looks like it sees the '~' as a literal part of the path and
does not actually resolve it correctly in the second scenario. It
looks like it assumes that it needs to append the relative path to the
front of the URL passed to Response.Redirect. If we use
Server.Transfer instead, it works just fine. Does anyone know why this
is the case?

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
6
by: \A_Michigan_User\ | last post by:
Ok, I give up... why do 1-4 work fine... but 5-6 give "can't find" errors? 1. Client-side VBscript code: call navigate("\\209.11.22.33\MyDir") 2. Client-side VBscript code: location.href...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
4
by: Harsh Thakur | last post by:
Hi, I'd like to know the performance related differences between Response.Redirect and Server.Transfer. I'd like to redirect the user to a different page. I can either do a...
3
by: Grant | last post by:
What is the difference between server.transfer(page.aspx) and redirect.response(page.aspx)? Some of the users get a blank page if I use redirect.response. I changed it to server.transfer because it...
3
by: Alan Silver | last post by:
Hello, Sorry if this is a stupid question, but I can't really see much difference between these tow methods according to the scant info in the SDK. Could anyone enlighten me? TIA -- Alan...
10
by: Bill | last post by:
In file FIRST.ASP, I've got <% Response.Redirect "SECOND.ASP" %> The redirect is happening, and I'm seeing the content from SECOND.ASP in the browser, but the URL in the browser is still...
2
by: Nathan Sokalski | last post by:
The last two lines of code in the Click event of a Button Control on my page are: Me.WelcomeEmail() Response.Redirect("mainmenu.aspx") The last line of code in Me.WelcomeEmail() is:
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.