How do I redirect to a page after successful login?

前端 未结 7 2038
梦谈多话
梦谈多话 2021-01-18 02:59

I\'m fairly new to web forms development, playing around with a project created using the ASP.NET Web Application template in VS 2010. After the user successfully logs in, I

相关标签:
7条回答
  • 2021-01-18 03:18

    I assume you're using ASP.NET Login control. There's a DestinationPageUrl property of that control that handles exactly that. If login was successfull user is redirected to URL provided in that property.

    0 讨论(0)
  • 2021-01-18 03:22

    After you checked for login:

    Response.Redirect("url");
    
    0 讨论(0)
  • 2021-01-18 03:30

    For Sharepoint farm solution development

    Page.Response.Redirect("url");
    
    0 讨论(0)
  • 2021-01-18 03:31
      <asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Admin/Default.aspx">
    </asp:Login>
    

    Go to Properties and Set DestinationPageUrl.

    0 讨论(0)
  • 2021-01-18 03:31

    The issue with Response.Redirect() is the 302. In some browsers (eg Chrome) this causes the new session cookie to be immediately invalidated.

    In other words, using that method to redirect causes the user to no longer be logged in, so you did not accomplish your purpose!.

    0 讨论(0)
  • 2021-01-18 03:36

    To simply redirect to a new page when your user has logged in, use the DestinationPageUrl property of your login control... assuming you're using the Login control that is.

    If you need to do anything more advanced you can use the OnLoggedIn event handler for your Login control to perform a redirect manually, or add any code for event logging and such.

    If you've rolled your own login control, and are just using things like text boxes and button controls, then in your Button_Click event, you can just use Response.Redirect("DestinationHere"); to take your users to a new page.

    0 讨论(0)
提交回复
热议问题