登录不能使用IE11的Web应用程序

dre*_*eza 2 forms-authentication asp.net-mvc-4 internet-explorer-11

我开发了一个使用表单身份验证和cookie的MVC4 Web应用程序.在所有浏览器中,自从我开始(几年)以来它一直运行良好.

我现在尝试从微软虚拟盒中使用IE11测试此站点,并且登录过程不起作用.当我点击登录时没有任何反应,我被重定向回登录页面,好像我没有经过身份验证.

起初我以为是因为cookie已经过期但是cookie被设置为我可以在临时文件中看到它.我的代码似乎没有做任何棘手的事情.

注意:当我将站点添加到兼容性视图时,登录过程有效

这是登录/ Cookie代码

public void SignIn(HttpResponseBase response, string userName, bool rememberMe)
{
    if (String.IsNullOrWhiteSpace(userName)) 
          throw new ArgumentException("Value cannot be null or empty.", "userName");

    var ticket = new FormsAuthenticationTicket(
                        1, 
                        userName, 
                        DateTime.Now, 
                        DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), 
                        rememberMe, 
                        string.Empty);

    var cookie = new HttpCookie(
                        FormsAuthentication.FormsCookieName, 
                        FormsAuthentication.Encrypt(ticket));
    cookie.HttpOnly = true;

    if (rememberMe)
    {
        cookie.Expires = ticket.Expiration;
    }

    response.Cookies.Add(cookie);
}
Run Code Online (Sandbox Code Playgroud)

我已经创建了一个自定义AuthorizeAttribute,它应该委托链,因为我没有通过ajax登录.

public class OverseerAuthorizeAttribute : AuthorizeAttribute
{
    protected override void HandleUnauthorizedRequest(AuthorizationContext context)
    {
        if (FormsAuthentication.IsEnabled)
        {
            if (context.HttpContext.Request.IsAjaxRequest())
            {
                context.HttpContext.Response.AddHeader("REQUIRES_AUTH", "1");
                context.Result = new EmptyResult();
            }
            else
            {
                base.HandleUnauthorizedRequest(context);
            }
        }
        else
        {
            base.HandleUnauthorizedRequest(context);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我从控制器中删除AuthorizeAttribute,那么系统会尝试登录,但由于没有用户名,因此会爆炸.当我把它放回去时没有任何反应.

Lon*_*per 5

尝试cookieless="UseCookies"formsweb.config文件的元素中使用attribute .那应该可以解决问题.阅读此处了解更多信息:

http://gyorgybalassy.wordpress.com/2013/09/23/aspnet-40-forms-authentication-issues-with-ie11/