944,193 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 12597
  • VB.NET RSS
Feb 20th, 2005
0

Facing the problem on "RedirectFromLoginPage"

Expand Post »
Hi All,

I now creating the login page. So I have using the
VB.NET Syntax (Toggle Plain Text)
  1. ForumsAuthentication.RedirectFromLoginPage(UserName.Text,False)

So by default it will redirect to the default.aspx
So this part is ok. Can I redirect to the another file name?

Another problem is, I will do the checking wheter the user is login. If user are not log in it will redirect to login.aspx I wrote code like:
VB.NET Syntax (Toggle Plain Text)
  1. If Session("Logged_IN").Equals("No") Then
  2. Response.Redirect("login.aspx")
  3. End If

But after I do the login and success, it will pop to the default.aspx. Can I redirect to the webpage where i original requested. I search from the web that ForumsAuthentication.RedirectFromLoginPage can redirect to caller webpage, but how? I feel blur!

Thanks
Best Regards
John Ang
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
johnangxun is offline Offline
1 posts
since Feb 2005
Apr 7th, 2005
0

Re: Facing the problem on "RedirectFromLoginPage"

Question 1: Can I redirect to the another file name?

Yes,
by changing the default page settings in/under IIS

Question 2: But after I do the login and success, it will pop to the default.aspx. Can I redirect to the webpage where i original requested.

I am not sure what you are asking here? What page you originally requested?

Do you mean one that was entered into the address bar, but forced you to the Login page?? Yup, sure can once you have logged in the session is started, keep the browser open and on the default.aspx page and enter or select the address in the browser address bar that you were trying to get to...and voila!

Hope this helps?

Quote originally posted by johnangxun ...
Hi All,

I now creating the login page. So I have using the
VB.NET Syntax (Toggle Plain Text)
  1. ForumsAuthentication.RedirectFromLoginPage(UserName.Text,False)

So by default it will redirect to the default.aspx
So this part is ok. Can I redirect to the another file name?

Another problem is, I will do the checking wheter the user is login. If user are not log in it will redirect to login.aspx I wrote code like:
VB.NET Syntax (Toggle Plain Text)
  1. If Session("Logged_IN").Equals("No") Then
  2. Response.Redirect("login.aspx")
  3. End If

But after I do the login and success, it will pop to the default.aspx. Can I redirect to the webpage where i original requested. I search from the web that ForumsAuthentication.RedirectFromLoginPage can redirect to caller webpage, but how? I feel blur!

Thanks
Best Regards
John Ang
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jul 17th, 2006
0

Re: Facing the problem on "RedirectFromLoginPage"

For a little more flexibility you can use the FormsAuthentication class to create the ticket and then manually redirect.


You can use your Web.config file to set specific users or check against a database. Then use the following to set up your ticket and redirect:

FormsAuthentication.SetAuthCookie(Uname.Text, False)

Response.Redirect("yourpage.aspx")

Thanks,

Dustin
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TraxionDesign is offline Offline
1 posts
since Jul 2006
Jul 27th, 2006
0

Re: Facing the problem on "RedirectFromLoginPage"

Hi,

You can use Server.Transfer instead of Response.Redirect to save a server round trip each time.

Loren Soth
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Aug 5th, 2006
0

Re: Facing the problem on "RedirectFromLoginPage"

Hi,

The code for the Button_Click() of Login page.

Sub Button_Click(By Val As Object, By Val As EventArgs)
If IsValid Then
If FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text) Then
FormsAuthentication.RedirectFromLoginPage(txtUsername.Tex,False)
Else
lblMessage.Text="Bad Username/Password")
End If
End If

End Sub

The above code will first check the username and password passed by the user. If they are valid, it will return true and then go to the next statement. Next, it creates an authentication cookie, attaches it to the outgoing response and redirects user to original requested page. The second parameter specifies whether the aurhentication should be a session cookie (false) or a persistent cookie(true).

the code for Default page

Sun Signout(ByVal objSender As Object,ByVal objArgs EventArgs)
FormsAuthentication.SignOut()
Response.Redirect(Request.UrlReferrer.ToString())

The code for Page_Load method

If user.Identity.IsAuthenticated Then
lblMessage.Text="Sucessful"
Else
lblMessage.Text="Sorry"
End if
End Sub


Regards
bhar
Knowledge is power
http://www.vkinfotek.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bharati Krishna is offline Offline
19 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: VB.Net communicating with MySQL Database.
Next Thread in VB.NET Forum Timeline: VB .Net Enterprise Edition





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC