MVCに新しく、自分のサイトを「ログアウト」しようとしています。 LogOn()メソッドとビューがあり、最初にログオンページが表示されます。私がログオンすると、ログアウトするためのボタンが付いた別のページに行きます。 (注:これは、直接イン/アウト、ロギングに関連しない可能性があり、私が働いているだけの話です。)MVC RedirectToActionが私のメソッドを見つけられない
<asp:Content runat="server" ContentPlaceHolderID="GlobalNavbarPrimary" ID="Content3">
<a href="<%= Url.Action("SignOut","Account") %>" class="ui-btn-right">Logout</a>
</asp:Content>
私はボタンを押すと、それが正しく私のサインアウトの方法を見つけます。しかし、私がログアウトした後、私はリダイレクトを実行してLogOnアクションに戻ります。なぜ私のLogOnメソッドが実行/発見されていないのか分かりません。ここに私のLogOnメソッドとSignOutメソッドがあります。
public ActionResult LogOn()
{
return View();
}
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
string sourceIp = string.Empty;
if (!string.IsNullOrEmpty(Request.UserHostAddress))
sourceIp = Request.UserHostAddress;
try
{
XX.User user = new XX.User();
XX.SessionKey sk = null;
sk = user.Logon(model.EmailAddress, model.Password, sourceIp);
Session[MyAuthorizeAttribute.MySessionKeyName] = sk.Value;
return RedirectToAction("Index", "Message");
}
catch (Exception ex)
{
ModelState.AddModelError(ex.Message, "Fatal Error");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
public ActionResult SignOut()
{
CM.User user = new CM.User(Key);
user.Logout(Key);
// This does not go to the LogOn action!!!!!
return RedirectToAction("LogOn", "Account");
は何も悩まれていることは、私がhttp://localhost:1159/#/Account/LogOnを見て期待していたのに対し、アドレスバーがhttp://localhost:1159/#/Account/SignOut示すことである(または.... // localhostを:1159 /)デバッグのため
任意の洞察力(や提案戦略)は大歓迎です。
jQuery-mobileベータ2のアップデートでこの問題が修正されました。 –