簡體   English   中英

umbraco 7.1注銷(剃刀語法C#)

[英]umbraco 7.1 logout (razor syntax C#)

我有一個umbraco 7.1網站,我使用自己的會員系統。我可以輕松登錄,查看我的狀態,甚至更改密碼但是沒有退出命令,我不知道我應該使用什么方法來umbraco 7注銷當前user.I知道我可以清除cookie和成員身份,但它總是會產生運行時錯誤。 幫我! :d

在后台(管理員)中,您可以添加新的部分視圖並選擇登錄狀態模板,您將獲得以下代碼。

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage

@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers

@{
    var loginStatusModel = Members.GetCurrentLoginStatus();

    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
    Html.RequiresJs("/umbraco_client/ui/jquery.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");

    var logoutModel = new PostRedirectModel();


    //Here you can specify a redirect URL for after logging out, by default umbraco will simply
    //redirect to the current page. Example to redirect to the home page:

    //logoutModel.RedirectUrl = "/"; 

}   // NOTE: This RenderJsHere code should be put on your main template page where the rest   of your script tags are placed
@Html.RenderJsHere()
@if (loginStatusModel.IsLoggedIn)
{
    <p>You are currently logged in as @loginStatusModel.Name</p>

   using (Html.BeginUmbracoForm<UmbLoginStatusController>("HandleLogout"))
   {
        <fieldset>
            <legend>Logout</legend>
            <button>Logout</button>
        </fieldset>

       @Html.HiddenFor(m => logoutModel.RedirectUrl)
   }
}

FormsAuthentication.SignOut();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM