| | |
Facing the problem on "RedirectFromLoginPage"
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I now creating the login page. So I have using the
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:
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
I now creating the login page. So I have using the
VB.NET Syntax (Toggle Plain Text)
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)
If Session("Logged_IN").Equals("No") Then Response.Redirect("login.aspx") 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
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?
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?
•
•
•
•
Originally Posted by johnangxun
Hi All,
I now creating the login page. So I have using the
VB.NET Syntax (Toggle Plain Text)
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)
If Session("Logged_IN").Equals("No") Then Response.Redirect("login.aspx") 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
•
•
Join Date: Jul 2006
Posts: 1
Reputation:
Solved Threads: 0
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
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
Hi,
You can use Server.Transfer instead of Response.Redirect to save a server round trip each time.
Loren Soth
You can use Server.Transfer instead of Response.Redirect to save a server round trip each time.
Loren Soth
Best regards,
Loren Soth
Crimson K. Software _________________________________________________________________ Crimson K. Blog
Loren Soth
Crimson K. Software _________________________________________________________________ Crimson K. Blog
•
•
Join Date: Aug 2004
Posts: 19
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- "Common" folder opens at start up (Windows NT / 2000 / XP)
- facing problem on smtp and tcp (Windows NT / 2000 / XP)
- I'm Facing A Problem (Java)
- google "keyword" question (Search Engine Optimization)
- Removal of "Home Search Assistant", "Search Extender", & "Shopping Wizard" (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: VB.Net communicating with MySQL Database.
- Next Thread: VB .Net Enterprise Edition
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add advanced application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity pan peertopeervideostreaming picturebox picturebox2 port print printpreview read record regex reports" reuse right-to-left save savedialog search serial socket sorting sqldatbase storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf xml





