Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Response.Redirect vs. Server.Transfer - using ~ operator

Reply
Thread Tools

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

 
 
jasonheath.net@gmail.com
Guest
Posts: n/a
 
      05-28-2008
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?
 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      05-28-2008
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.


<> wrote in message
news:e163c25e-6f8f-40e0-92a4-...
>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?



 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      05-28-2008
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
<> wrote in message
news:e163c25e-6f8f-40e0-92a4-...
>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?


 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      05-29-2008
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]" <> wrote in message
news:1A07629E-7B8C-47D6-ACD1-...
> 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
> <> wrote in message
> news:e163c25e-6f8f-40e0-92a4-...
>>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?

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Member operators operator>>() and operator<<() Alex Vinokur C++ 3 03-20-2005 03:11 PM
How to calculate size of an int without using the sizeof operator but using bitwise operator Manish_Ganvir C Programming 13 02-14-2005 07:24 PM
operator*(Foo) and operator*(int) const: ISO C++ says that these are ambiguous: Alex Vinokur C++ 4 11-26-2004 11:46 PM
Operator overloading on "default" operator John Smith C++ 2 10-06-2004 10:22 AM
Q: operator void* or operator bool? Jakob Bieling C++ 2 03-05-2004 04:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57