In my web application, I have 2 users and 2 roles. I want to redirect the users to different pages based on the roles.
I used the following code to Login_LoggedIn event handler:
if(Roles.IsUserInRole(Login.UserName,"Member"))
Response.Redirect("~Protected/frmMemberHome.aspx");
else if(Roles.IsUserInRole(Login.UserName,"Admin"))
Response.Redirect("~Admin/frmAdminPanel.aspx");
Now, this doesn’t work for me. the event don’t fire itself. In my case, after successful logging only the Login page is refreshed automatically and absolutely nothing happens.
Some of the forums on the Internet suggests to set the DestinationPageURL property of the Login Control of ASP.NET, but my problem is I can not redirect all users to the same URL, I need to change the DestinationPageURL based on roles.
this is my UserLogin page:
<%@ Page Title="" Language="C#" MasterPageFile="~/mainLayout.Master" AutoEventWireup="true" CodeBehind="frmUserLogin.aspx.cs" Inherits="OnlineTMS_MIST.frmUserLogin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Login ID="Login" runat="server"
DisplayRememberMe="False">
</asp:Login>
</asp:Content>
I have no idea, what to do. Whatever other forums suggested is the same thing I tried before but not worked for me.
Compare your login control markup and mine.
it’s mine:
I think you have not bind the event with the event handler. this section is missing
onloggedin="Login1_LoggedIn"in your markup. If you have done it on Page_Init event as:Firtly check this and update whether it working or not..