Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. after login always go default page

after login always go default page

Scheduled Pinned Locked Moved ASP.NET
securitytutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyHelp
    wrote on last edited by
    #1

    I have my login page using user.authentication when everytime i login, it will go to default page. How to make it when I login, it go back to the page itself. Mean if now i at page1.aspx and I didnt login, so a login form will pop up requeir I to login. After login I want my page to show the page1.aspx but not go to default.aspx Sub Authenticate(ByVal Sender As [Object], ByVal e As EventArgs) Dim u_id As Integer = DBAuthentication(txtUsername.Text, txtPassword.Text) Dim cookie As HttpCookie = FormsAuthentication.GetAuthCookie(txtUsername.Text, chkPersistCookie.Checked) If u_id > 0 Then FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, True) cookie.Expires = DateTime.Now.AddDays(14) Response.Cookies.Add(cookie) Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUsername.Text, chkPersistCookie.Checked)) Else lblMessage.Text = "This login doesn't exits.
    " + "Please check your username/password.
    " End If End Sub

    M 1 Reply Last reply
    0
    • L LovelyHelp

      I have my login page using user.authentication when everytime i login, it will go to default page. How to make it when I login, it go back to the page itself. Mean if now i at page1.aspx and I didnt login, so a login form will pop up requeir I to login. After login I want my page to show the page1.aspx but not go to default.aspx Sub Authenticate(ByVal Sender As [Object], ByVal e As EventArgs) Dim u_id As Integer = DBAuthentication(txtUsername.Text, txtPassword.Text) Dim cookie As HttpCookie = FormsAuthentication.GetAuthCookie(txtUsername.Text, chkPersistCookie.Checked) If u_id > 0 Then FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, True) cookie.Expires = DateTime.Now.AddDays(14) Response.Cookies.Add(cookie) Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUsername.Text, chkPersistCookie.Checked)) Else lblMessage.Text = "This login doesn't exits.
      " + "Please check your username/password.
      " End If End Sub

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You shouldn't call the RedirectFromLoginPage method, instead you can get the originally requested page from the ReturnUrl key in the query string, then use the Redirect method to throw the user back to that page, you can see an example from here[^].

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups