In the webmatrix2 starter site once you have logged in there is a the following link; "hello" bob@example.com {logout}
Clicking on the link will take you to a manage section however I would like it to go to a custom manage user profile page or business profile page depending on the role of the member that logged in. So in essence the code will check the user role and then depending on that role redirect to url(user manager) or (admin manager)
Is there any way to do this programattically in razor.
<section id="login">
@if (WebSecurity.IsAuthenticated) {
<text>Hello, <a class="email" href="~/Account/Manage" title="Manage">@WebSecurity.CurrentUserName</a>!
<form id="logoutForm" action="~/Account/Logout" method="post">
@AntiForgery.GetHtml()
<a href="javascript:document.getElementById('logoutForm').submit()">Log out</a>
</form>
</text>
} else {
<ul>
<li><a href="~/Account/Register-User">Register</a></li>
<li><a href="~/Account/Login">Log in</a></li>
</ul>
}
</section>
You can use a conditional block to render links depending on the Role which you can determine by using the Roles.IsUserInRole() method:
@if(Roles.IsUserInRole("User Manager")){
<a href="~/ManageUser">Click</a>
}
@if(Roles.IsUserInRole("AdminManager")){
<a href="~/ManageAdmin">Click</a>
}
Or you can leave the link as it is, and the determine which role the user is in once they land on the Manage page.