我有一個MVC應用程序,具有不同的用戶帳戶和密碼。登錄功能工作正常,但當我點擊註銷按鈕時,我得到一個404錯誤說:退出按鈕不能在mvc應用程序中工作
'/'應用程序中的服務器錯誤。
無法找到該資源。 描述:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。
請求的URL:/帳號/註銷
這是註銷按鈕的代碼:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Log Off", "LogOff", "Account")</li>
</ul>
</div>
這是的AccountController
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
Session.Clear();
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
我相信這是HttpPost屬性。你有沒有嘗試刪除它。 – Pharylon