1
在webmatrix2初學者網站中,一旦您登錄,就會出現以下鏈接; "hello" [email protected] {logout}
Webmatrix2 - 根據Razor中的UserRole進行的Url重定向
點擊該鏈接將帶你到一個管理部分,但是我想它去定製取決於登錄的成員的角色管理用戶的個人資料頁或業務的個人資料頁。因此,在本質代碼將檢查用戶角色,然後根據該角色重定向到URL(用戶管理器)或(管理員管理器)
有沒有辦法在剃鬚刀中執行此程序。
<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>
嗨邁克感謝這麼多,完美的工作,我已經添加下面更新的代碼。非常感謝丹 – daninoz 2013-03-18 23:42:58
@if(WebSecurity.IsAuthenticated){ 你好, @if(Roles.IsUserInRole( 「用戶」)){ @WebSecurity.CurrentUserName } @if(Roles.IsUserInRole( 「交易」)){ @WebSecurity.CurrentUserName } –
daninoz
2013-03-18 23:46:31