Page redirection based on user role in ASP.Net

Last Reply on Jun 22, 2016 08:18 AM By dharmendr

Posted on Jun 21, 2016 07:43 AM


how to navigate to 2 different paths according to current path

as example I have default.aspx in 2 directories 

how to make linkbutton navigate to app/admin/default.aspx if admin press on it
and to app/default.aspx if normal user press on  it


Mehad Araby




You are viewing reply posted by: dharmendr on Jun 22, 2016 08:18 AM.
Posted on Jun 22, 2016 08:18 AM Modified on on Jun 22, 2016 08:47 AM

Hi mehad,

Refer the below html. LinkButton doesnot have property NavigateUrl, it has PostBackUrl.

    <asp:LinkButton ID="lbNavigate" Text="Details" runat="server" OnClick="lbNavigate_Click" />


protected void lbNavigate_Click(object sender, EventArgs e)
    string userType = "admin"; //Get usertype as per your logic.
    if (userType.ToLower() == "admin")
        lbNavigate.PostBackUrl = "~/app/admin/Default.aspx";
        lbNavigate.PostBackUrl = "~/app/Default.aspx";