 |
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

May 6th, 2010, 10:33 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok explain what this line of code in the Wrox book is supposed to do.
FormsAuthentication.RedirectFromLoginPage(User.Tex t, true);
Desmond
is it
a:) do nothing and keep me on the login page
b:) Allow me to navigate around the website as an authorised user
|

May 6th, 2010, 10:39 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Actualy the line in the book says
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, true);
Not
FormsAuthentication.RedirectFromLoginPage(User.Tex t, true);
I changed the name of the textbox control
|

May 6th, 2010, 10:42 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry my mistake I changed the false to a true to see if that was an aerror in the book. The book says
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, False);
|

May 6th, 2010, 10:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
So is it solved now?
Imar
|

May 6th, 2010, 10:50 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No it is not solved. Question REMAINS STILL
What is this line in the book supposed to do
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, False);
Note that it it says False and not false.
Code in login form ...............
protected void submit1_Click(object sender, EventArgs e)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, False);
}
This should do what?
|

May 6th, 2010, 10:55 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Why don't you look it up in the docs? The following URL is the "I feel lucky" in Google for RedirectFromLoginPage and provides valuable insights in this method.
http://msdn.microsoft.com/en-us/library/1f5z1yty.aspx
Cheers,
Imar
|

May 6th, 2010, 11:02 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes thats what I thought it did but it does not. WHY
Redirects an authenticated user back to the originally requested URL or the default URL using the specified cookie path for the forms-authentication cookie.
Page 679 of your book
<system.web>
<authentication mode="Forms">
<forms name="Wrox" loginUrl="Login.aspx" path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
I have a page Login.aspx (Suprise suprise) with this code
protected void submit1_Click(object sender, EventArgs e)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, True);
}
as per your page 685.
This just keeps me on the Login.aspx page
|

May 6th, 2010, 11:16 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
There is an error in your book. The link you told me to go to states ...
public static void RedirectFromLoginPage(string userName, bool createPersistentCookie, string strCookiePath)
Can you count?
There are 3 arguments to this function not 2 as in
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, False);
|

May 6th, 2010, 11:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I am sorry, but you may be barking up the wrong tree here. Before we continue, let's set one thing straight:
It's not my page, nor my book. I am here on this forum just as a visitor; nothing more nothing less.
The example you're posting works fine for me with this Login page:
Code:
protected void Button1_Click(object sender, EventArgs e)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
}
if I redirect Login.aspx page directly. When I enter a name, I am taken back to Default.aspx.
Are you sure your code is OK? Is the code you posted a direct copy or did you type it for this post? (It's true, not True). Also, maybe you have something in your query string?
Imar
|

May 6th, 2010, 11:26 AM
|
Registered User
|
|
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am using invisible ink. There is no query or database. If you look at the code
protected void submit1_Click(object sender, EventArgs e)
{
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, false);
}
you will notice that there is no query. I am just testing this out. I am not bothered at this stage about doing a query. This is a TEST page. The line
FormsAuthentication.RedirectFromLoginPage(TextBox1 .Text, false);
should allow me to carry on as usual. It keeps me on the login page.
The FormsAuthentication.RedirectFromLoginPage takes 3 arguments not 2
The code in the web.config file is as stated in the wrox book.
<system.web>
<authentication mode="Forms">
<forms name="Wrox" loginUrl="Login.aspx" path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
This has been copied and pasted. This has not been typed into this forum
|
|
 |