1

I am using asp.net mvc4 application.Here i am using the form authentication.My scenario is like this, after authentication the auth token is not passing in the request header when i am using IE.But it is working fine with chrome and Mozilla .Here my authentication is done in first method and the second method i am calling is an ajax call.Is their any problem with ajax call?

First authenticating method is getjson method.Then i am using an ajax call.

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) {

                    }

                });
            }
Sajeev
  • 197
  • 9
  • Check this out http://stackoverflow.com/questions/19725827/internet-explorer-11-session-issue-with-asp-net-4-0 – Panama Jack Jan 13 '14 at 12:55
  • @Pjack http://stackoverflow.com/questions/19725827/internet-explorer-11-session-issue-with-asp-net-4-0 i have tried this.but it works fine for first login.Then again the issue comes,ie the auth cookie is not sending – Sajeev Jan 15 '14 at 05:09

2 Answers2

0

Source SO

IE suffers from a weird bug - for some reasons, if there are non-alphanumeric characters in the domain's name, IE won't persist cookies... and hence you'll have no persistent session between different calls.

Check if your domain has non-alphanumeric characters in it, such as test_domain or test-domain or the likes.

Got solution from 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>

also.. The problem rests with some IIS instances thinking that IE10 is a cookieless browser (i.e. cant support cookies). In our problem case the server was setting the authentication cookie and sending it back to the browser, but was then ignoring the cookie on subsequent requests.

The solution is to either patch the browser capabilities so that it knows IE10 can do cookies (outlined in another answer on this page), or change the default behaviour to force it to use cookies even if it thinks the browser can’t do cookies.

We just added the following to our forms section in web.config:

cookieless="UseCookies"

<authentication mode="Forms">
  <forms name=".AUTH" cookieless="UseCookies" loginUrl="/" timeout="10000" path="/" />
</authentication>
Community
  • 1
  • 1
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73
  • My domain doesn't contain any special symbols.when i degrade my browser to ie 9 its working fine.Can suggest any idea to solve this – Sajeev Jan 13 '14 at 12:55
  • @Sajeev check edited answer it is from link which is posted in my answer – Nilesh Gajare Jan 13 '14 at 13:03
  • i have tried the above in my asp.net mvc application.But it works fine for my first login.During my second time login the auth cookies are not sent in the request header – Sajeev Jan 15 '14 at 05:28
  • @Sajeev try changing the name of the authentication cookie, by setting the following in Web.config ` ` – Nilesh Gajare Jan 15 '14 at 05:56
  • i have tried it.After clearing the cache,First time login is possible.During the second login the same problem is comming i can't able to login – Sajeev Jan 16 '14 at 04:56
0

Check the version of .net running on your server for your asp.net applications. You might need at least 4.5. IE 11 has some known issues.

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

Here's another link with a similar issue.

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

Community
  • 1
  • 1
Panama Jack
  • 24,158
  • 10
  • 63
  • 95