Asp.net mvc 自定义表单授权注销重定向到其他页面?

Asp.net mvc 自定义表单授权注销重定向到其他页面?,asp.net-mvc,Asp.net Mvc,我正在使用asp.NETMVC5和自定义表单验证。当我尝试登录它登录完美,但当我尝试注销它重定向到我在下面给出的webconfig文件中设置的logiurl <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="30" /> </authentication> 在chrome浏览器中一切正常,但在firefox中却无法正常工作。这种方法已被弃用,尽管它对测试很有用,但

我正在使用asp.NETMVC5和自定义表单验证。当我尝试登录它登录完美,但当我尝试注销它重定向到我在下面给出的webconfig文件中设置的logiurl

<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="30" />
</authentication>

在chrome浏览器中一切正常,但在firefox中却无法正常工作。

这种方法已被弃用,尽管它对测试很有用,但我不再使用它,而是使用我自己定制的已实现模板,在安全方面,客户是第一位的

话虽如此,关于您使用的类和模型,我还有一个尚未回答的问题

使用表单身份验证功能需要调用System.Web.Security.FormsAuthentication类的两个静态方法:

  • Authenticate方法验证用户提供的凭据
  • SetAuthCookie方法将cookie添加到对 浏览器,这样用户就不必每次访问时都进行身份验证 提出请求
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Logoff()
{
 _formsAuth.SignOut();
 return RedirectToAction("Index", "Home");
}   
public class FormsAuthProvider : IAuthProvider {
    public bool Authenticate(string username, string password){
        bool result = FormsAuthentication.Authenticate(username, password);
        if (result) {
            FormsAuthentication.SetAuthCookie(username, false);
        }
        return result;
    }


public class AccountController : Controller {
    IAuthProvider authProvider;
    public AccountController(IAuthProvider auth) {
        authProvider = auth;
    }
    public ViewResult Login() {
        return View();
    }
    [HttpPost]
    public ActionResult Login(LoginViewModel model, string returnUrl) {
        if (ModelState.IsValid) {
            if (authProvider.Authenticate(model.UserName, model.Password)) {

                return Redirect(returnUrl ?? Url.Action("Index", "Admin"));
            } else {
                ModelState.AddModelError("", "Incorrect username or password");
                return View();
            }
        } else {
            return View();
        }
    }
}