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. login and Default.aspx page

login and Default.aspx page

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
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.
  • J Offline
    J Offline
    jetset32
    wrote on last edited by
    #1

    Hi all, Im coming to the end of my project and my last prob is this! When a user goes directly to the login page and enters correct details in, they get redirected to the 'Default.aspx' page, I want them to be redirected to the 'Home.aspx' page. The question is , how to change the 'Default' page to 'home' page. I want to keep using the FormsAuthentication.RedirectFromLoginPage(customerId, True) Because i dont want the user to ALWAYS be directed to the Home page. Thanks in advance Jetset!

    M 1 Reply Last reply
    0
    • J jetset32

      Hi all, Im coming to the end of my project and my last prob is this! When a user goes directly to the login page and enters correct details in, they get redirected to the 'Default.aspx' page, I want them to be redirected to the 'Home.aspx' page. The question is , how to change the 'Default' page to 'home' page. I want to keep using the FormsAuthentication.RedirectFromLoginPage(customerId, True) Because i dont want the user to ALWAYS be directed to the Home page. Thanks in advance Jetset!

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

      Hi there, IMHO, you first need to understand how the FormsAuthentication.RedirectFromLoginPage method works. Basically, the method will redirect the user to the originally requested page specified in the query string with the ReturnUrl key. If this key is not found, the user is always redirected to the Default.aspx at root. Here, you want to keep using this method, so IMO there are a couple of options come to mind: + If you want the user to be redirected to his originally requested page, you first check if the ReturnUrl key exists in the query string before calling the RedirectFromLoginPage. If the key does not exist, you can use the Response.Redirect method to go to the home.aspx page. If you don't want to do the checking, you can simply create a default.aspx at root, in this default page, you simply redirect the user to your home page home.aspx. + If you want the user to always be directed to the home.aspx page, you should use the Response.Redirect method instead of the FormsAuthentication.RedirectFromLoginPage. Or you can think of removing the ReturnUrl key in the query string with the sample code like this in the Page_Load event handler of the login page:

      private void Page_Load(object sender, System.EventArgs e)
      {
      if(!IsPostBack && Request.QueryString["ReturnUrl"]!=null)
      {
      Response.Redirect(Request.Url.AbsolutePath);
      }
      }

      For more information, see RedirectFromLoginPage [^]

      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