身份验证令牌未通过IE

问题描述:

我正在使用asp.net mvc4 application.Here我使用表单身份验证。我的情况是这样的,身份验证后身份验证令牌没有传递请求头时,我使用IE但它在Chrome和Mozilla中运行正常。在这里我的身份验证是在第一种方法中完成的,而我所调用的第二种方法是ajax调用。是否有任何与ajax调用有关的问题?身份验证令牌未通过IE

第一种验证方法是getjson方法。然后我使用ajax调用。

if (user != "" && passwd != "" && location != "" && location != -1) { 
     $.getJSON(window.contexthttproot + "/Account/Location", { 'Username': user, 'Password': passwd }, function (items) { 

     if (items.length > 0) { 
          $('#Serverow').hide(); 
          $('#locate').show(); 
          $('#location').show(); 


    $("#Username").attr("disabled", "disabled"); 
         $("#Password").attr("disabled", "disabled"); 
         $("#Location").fillSelect($.map(items, function (item) { 
          return { 
           ID: item.LocationID, 
           Name: item.LocationName 
          }; 
         })); 
         setTimeout(function() { 
          $('#spinner').fadeOut('fast'); 
         }) 
        } 
        else { 
         setTimeout(function() { 
          $('#spinner').fadeOut('fast'); 

         }) 

        } 
       }); 
      } 
} 


    if (user != "" && passwd != "" && location != "" && location != -1) { 

       var json = "{'location':'" + location + "','locationName':'" + loctext + "'}"; 

       $.ajax({ 
        url: window.contexthttproot + "/Report/ReportLocation", 
        type: 'POST', 
        datatype: "json", 
        contentType: "application/json; charset=utf-8", 
        cache: false, 
        data: json, 
        success: function (items) { 

         window.location.replace("/LandingPage/Landing"); 
         setTimeout(function() { 
          $('#spinner').fadeOut(35000); 
         }) 
        }, 
        error: function (xhr, status) { 

        } 

       }); 
      } 
+0

什么版本的IE? –

+0

看看这个http://*.com/questions/19725827/internet-explorer-11-session-issue-with-asp-net-4-0 –

+0

@Pjack使用IE 11. – Sajeev

源,以便

IE从一个奇怪的错误遭受 - 因为某些原因,如果在域的名称非字母数字字符,IE不会存留饼干......,因此你会不同呼叫之间没有持续会话。

检查您的域中是否包含非字母数字字符,如test_domain或test-domain或诸如此类。从here

== Workaround == 

In the meantime to make it work and to avoid similar issues in the future, I use a file ~\App_Browsers\BrowserFile.browser with the following: 

<browsers> 
<browser refID="Default"> 
<capabilities><!-- To avoid wrong detections of e.g. IE10 --> 
<capability name="cookies" value="true" /> 
<capability name="ecmascriptversion" value="3.0" /> 
</capabilities> 
</browser> 
</browsers> 

得到解决.. 的问题在于一些IIS实例认为IE10是一个cookie的浏览器(即倾斜支持Cookies)。在我们的问题案例中,服务器设置了身份验证cookie并将其发送回浏览器,但随后忽略了cookie。

解决方案是修补浏览器功能,以便它知道IE10可以执行cookie(在本页的另一个答案中概述),或者更改默认行为以强制它使用cookie,即使它认为浏览器可以'不要做饼干。

我们刚刚添加以下到我们的表格节在web.config中:

无Cookie =“UseCookies”

<authentication mode="Forms"> 
    <forms name=".AUTH" cookieless="UseCookies" loginUrl="/" timeout="10000" path="/" /> 
</authentication> 
+0

我的域名不包含任何特殊符号。当我降级我的浏览器到ie 9它的工作很好。可以建议任何想法来解决这个 – Sajeev

+0

@Sajeev检查编辑答案它是从我的回答中发布的链接 – Nilesh

+0

我已经在我的asp.net mvc应用程序中尝试了上述方法。但它对我的第一次登录很有效。在我第二次登录时,验证cookie不会发送到请求标头 – Sajeev

检查.NET版本的服务器上为你的asp.net应用程序运行。您可能需要至少4.5。 IE 11有一些已知的问题。

http://www.microsoft.com/en-us/download/details.aspx?id=30653

这里有一个类似的问题,另一个链接。

IE11 and the .NET User.Identity.IsAuthenticated always returns false