使用asp.net mvc4。我無法從我的應用中打開〜/帳戶/註銷。默認路由應該捕獲它並將其路由到適當的控制器。在routeconfig.cs中asp.net mvc4註銷鏈接路由未找到
routes.MapRoute(
name: "Home",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
不應該那麼抓網址嗎?
代碼的鏈接創建
@Html.ActionLink("Signout", "LogOff", "Account" , new{controller = "Account"
, action = "LogOff"}, new{ target = "_self"})
出於某種原因,是推動我瘋了,我不能打
//
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
var fam = FederatedAuthentication.WSFederationAuthenticationModule;
fam.SignOut(false);
SignOutRequestMessage signOutRequest = new SignOutRequestMessage(new Uri(fam.Issuer), fam.Realm);
return new RedirectResult(signOutRequest.WriteQueryString());
}
我已經試過之前和之後的「主頁添加路由「maproute。兩人似乎都沒有工作。我在這裏錯過了什麼?我寫了幾十個asp.net mvc應用程序,並沒有遇到這個問題。這是在吹我的腦海。請幫忙。
乾杯, 〜CK
看起來很完美。我的猜測是路線和鏈接得到匹配的權利,但方法沒有。不能指出任何明確的*理由*。我會開始刪除antiforgerytoken。如果用戶僞造註銷,任何人都不會受到影響 –