471,582 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How does this code work?(Request["ReturnUrl"])

I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.
Nov 30 '06 #1
7 23647
That is using the indexer for the object to index into it by name.

"vvkl" <ma******@hotmail.comwrote in message
news:OR**************@TK2MSFTNGP05.phx.gbl...
>I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.

Nov 30 '06 #2
I can't understant well.
Could you give an example?
I want to know when is the Request["ReturnUrl"]'s value not null?

"Marina Levit [MVP]" <so*****@nospam.com写入消息新闻:%2**************** @TK2MSFTNGP05.phx.gbl...
That is using the indexer for the object to index into it by name.

"vvkl" <ma******@hotmail.comwrote in message
news:OR**************@TK2MSFTNGP05.phx.gbl...
>>I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.


Nov 30 '06 #3
That is a feature of authentication. When you try and access a page
without logging in, asp.net will redirect you to the login page. The
value in the "ReturnURL" value of the query string will be the page
you original requested

On Fri, 1 Dec 2006 00:23:48 +0800, "vvkl" <ma******@hotmail.com>
wrote:
>I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 30 '06 #4
Well, I'm codding a login function.
I've tried and accessed page "CustomerDetail.aspx" without logging in, then
redirected to page "login.aspx" .But, after authenticated, my code dosen't
work.

string strRedirect = Request["ReturnUrl"];
if(strRedirect == null)
strRedirect = "MyDetail.aspx";
Response.Redirect(strRedirect, true);

the value of "strRedirect" always is null.
How can "Request["ReturnUrl"]" get value?

"Rad [Visual C# MVP]" <no****@nospam.com>
??????:sq********************************@4ax.com. ..
That is a feature of authentication. When you try and access a page
without logging in, asp.net will redirect you to the login page. The
value in the "ReturnURL" value of the query string will be the page
you original requested

On Fri, 1 Dec 2006 00:23:48 +0800, "vvkl" <ma******@hotmail.com>
wrote:
>>I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.
--

Bits.Bytes.
http://bytes.thinkersroom.com

Dec 1 '06 #5
>I've tried and accessed page "CustomerDetail.aspx" without logging in, then
>redirected to page "login.aspx" .But, after authenticated, my code dosen't
work.
string strRedirect = Request["ReturnUrl"];
if(strRedirect == null)
strRedirect = "MyDetail.aspx";
Response.Redirect(strRedirect, true);

the value of "strRedirect" always is null.
How can "Request["ReturnUrl"]" get value?
You need to put that onto the URL when you call up your page - e.g. if
your client tries to access "CustomerDetail.aspx" and gets redirected
to the login.aspx page, you'll need to do something like:

login.aspx?ReturnUrl=CustomerDetail.aspx

That way, you'll get the "ReturnUrl" in your Request[..] object.

Marc
Dec 1 '06 #6
You do me a big favor!
Thank you!

"Marc Scheuner" <no*****@for.me>
??????:0i********************************@4ax.com. ..
I've tried and accessed page "CustomerDetail.aspx" without logging in,
then
redirected to page "login.aspx" .But, after authenticated, my code dosen't
work.
string strRedirect = Request["ReturnUrl"];
if(strRedirect == null)
strRedirect = "MyDetail.aspx";
Response.Redirect(strRedirect, true);

the value of "strRedirect" always is null.
How can "Request["ReturnUrl"]" get value?

You need to put that onto the URL when you call up your page - e.g. if
your client tries to access "CustomerDetail.aspx" and gets redirected
to the login.aspx page, you'll need to do something like:

login.aspx?ReturnUrl=CustomerDetail.aspx

That way, you'll get the "ReturnUrl" in your Request[..] object.

Marc

Dec 2 '06 #7
You need to setup your authentication properly. In particular change
the web config such that it denies anonymous logons.

That way ASP.NET will automatically populate the ReturnURL parameter
if you access a page without logging on.

On Fri, 1 Dec 2006 13:12:05 +0800, "vvkl" <ma******@hotmail.com>
wrote:
>Well, I'm codding a login function.
I've tried and accessed page "CustomerDetail.aspx" without logging in, then
redirected to page "login.aspx" .But, after authenticated, my code dosen't
work.

string strRedirect = Request["ReturnUrl"];
if(strRedirect == null)
strRedirect = "MyDetail.aspx";
Response.Redirect(strRedirect, true);

the value of "strRedirect" always is null.
How can "Request["ReturnUrl"]" get value?

"Rad [Visual C# MVP]" <no****@nospam.com>
??????:sq********************************@4ax.com ...
>That is a feature of authentication. When you try and access a page
without logging in, asp.net will redirect you to the login page. The
value in the "ReturnURL" value of the query string will be the page
you original requested

On Fri, 1 Dec 2006 00:23:48 +0800, "vvkl" <ma******@hotmail.com>
wrote:
>>>I have readed a example code from MSDN about FormsAuthenticationTicket
calss, but there's a line I can't understand :
'strRedirect = Request["ReturnUrl"];'
What's the mean in which square brackets?

Thank you!

A Chinese student.
--

Bits.Bytes.
http://bytes.thinkersroom.com
--

Bits.Bytes.
http://bytes.thinkersroom.com
Dec 2 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Paul THompson | last post: by
162 posts views Thread by Isaac Grover | last post: by
14 posts views Thread by Anoop | last post: by
14 posts views Thread by webEater | last post: by
1 post views Thread by =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by

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.