我有一个 umbraco 7.1 网站,我使用它自己的成员(member)系统。我可以轻松登录,查看我的状态,甚至更改密码,但没有注销命令,我不知道我应该为 umbraco 7 使用什么方法注销当前用户。我知道我可以清除 cookie 和成员身份,但它总是会出现运行时错误。 帮我! :D
最佳答案
在后台(管理员)您可以添加一个新的局部 View 并选择登录状态模板,您将获得以下代码。
@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)
}
}
关于c# - umbraco 7.1 注销(razor 语法 C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25365454/