可能性の重複ログアウトのまま動作しない:ここで私はのは、ログインして関連している私のコードの一部を与えている
Loginstatus not working while i want to logout in remains logoutLoginstatusは私がログアウトしたいながら...それは
I am studding a tutorial on asp.net mvc which name is MvcMusicStore. I am creating MvcBookStore For login and logout i use the facility of ASP.net configuration. I am successful in login but unsuccessful in logout using loginstatus from toolbox.
とログアウト:
私のコントローラのフォルダで私はを使用StoreManagerController.csを作成しました[Authorize(Roles = "Administrator")]ネームスペースMvcBookStore.Controllersの内部。
私はファイルAccountModel.csと私はのは、必要なコードを与えているの下に作成したモデルのフォルダに今namespace MvcBookStore.Controllers
{
[Authorize(Roles = "Administrator")]
public class StoreManagerController : Controller
{
// code goes here...
}
}
:
namespace MvcBookStore.Models
{
#region Services
public interface IFormsAuthenticationService
{
void SignIn(string userName, bool createPersistentCookie);
void SignOut();
}
public class FormsAuthenticationService : IFormsAuthenticationService
{
public void SignIn(string userName, bool createPersistentCookie)
{
ValidationUtil.ValidateRequiredStringValue(userName, "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
}
public void SignOut()
{
FormsAuthentication.SignOut();
}
}
時には、上記のコードが自動的に追加され 形式は以下の通りでありますasp.net mvcのWebサイトが作成されます。私は何も変えていない。 VisualStudio 2010でLoginStatus機能を使用したいと思います。それは自動的にログアウトURLを見つけるためです。私はView/StoreManager/Index.aspxの位置に追加しています。コードは次のとおりです:
<%@ Page Title="" Language="C#" AutoEventWireup ="true" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcBookStore.Models.Album>>" %>
<script runat="server">
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("/View/Home/Index.aspx");
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<h2>Index
<asp:LoginStatus ID="LoginStatus1" runat="server"
onloggingout="LoginStatus1_LoggingOut"
LogoutAction="Redirect" />
</h2>
<table>
<tr>
<th></th>
<th>Title</th>
<th>Artist</th>
<th>Genre</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%: Html.ActionLink("Edit", "Edit", new { id=item.AlbumId }) %> |
<%: Html.ActionLink("Delete", "Delete", new { id=item.AlbumId })%>
</td>
<td><%: Html.Truncate(item.Title, 25) %></td>
<td><%: Html.Truncate(item.Artist.Name, 25) %></td>
<td><%: item.Genre.Name %></td>
</tr>
<% } %>
</table>
<p>
<%: Html.ActionLink("Create New", "Create") %>
</p>
<p>
<a href="/Control/ordercontrol.aspx" > control order</a>
</p>
</form>
</asp:Content>
すべてのことはOKですが、ログアウトリンクをクリックしても何もしません。
MVCの仕組みを学ぶ必要があります。 – SLaks
同じ質問を2回お送りください** http://stackoverflow.com/questions/10417080/loginstatus-not-working-while-i-want-to-logout-in-remains-logout** –