locked
Redirect user based on login RRS feed

  • Question

  • User-807418713 posted

    Hello

    In my masterpage asp.net im using this below code

     <%if (HttpContext.Current.User.Identity.Name == "userlocal") { %>
    
    
    
        <%} %>

    If user comes with this login it should directly redirect to  Track.aspx

    How to do so..?

    Wednesday, July 4, 2018 9:40 AM

Answers

  • User-1171043462 posted

    in ASPX of Master Page add

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.User.Identity.Name == "userlocal") 
         {    
                 Response.Redirect("Track.aspx"); 
         }
    }
    </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 4, 2018 6:33 PM

All replies

  • User-1171043462 posted

    Why you check in Master Page, instead you must check just after Login is successful and send user to the page.

    //Login Done
    if (HttpContext.Current.User.Identity.Name == "userlocal") 
    { Response.Redirect("Track.aspx"); }
    And same thing do in Master
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.User.Identity.Name == "userlocal") 
         {    
                 Response.Redirect("Track.aspx"); 
         }
    }

    Page Page Load

    Wednesday, July 4, 2018 10:04 AM
  • User-807418713 posted
    Hello

    Can it be done via aspx page if yes then how would be the code...

    Thank You
    Wednesday, July 4, 2018 5:47 PM
  • User-1171043462 posted

    In ASPX also you will have to use Page Load event. It is not possible in any other way.

    Wednesday, July 4, 2018 6:04 PM
  • User-807418713 posted
    Hello...

    Can you give me one example in aspx page based on my code..
    Wednesday, July 4, 2018 6:31 PM
  • User-1171043462 posted

    in ASPX of Master Page add

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.User.Identity.Name == "userlocal") 
         {    
                 Response.Redirect("Track.aspx"); 
         }
    }
    </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 4, 2018 6:33 PM