Ashx internet explorer problem

My problem is a little tricky: I am writing in C #, asp.net and using jquery

  • I have a page that sends requests to the server using the jquery ajax Method.
  • I have an ashx file (handler) to answer this request.
  • User can make multiple changes to multiple pages, then use some method which will call the ajax method.
  • My ashx file reads some values. session variables and actions, respectively.

This works fine in all browsers, but in Internet Explorer. In Internet Explorer, the session seems to contain old information (old user IDs). It's incredible, the same code works fine in firefox, chrome and safari, but doesn't work with.

What could be the reason? I have no idea where to even start looking for a solution.

btw, Sorry for the general title, couldn't figure out how to explain in just a few words.

Here is the jquery and ashx code:

JQuery

function SendRequstToServer(actionId, additional, callback) {
    if (actionId == "-1") {
        document.location = "default.aspx";
    }
    $.ajax({ url: "SmallRoutinesHandler.ashx", method: "GET",
    //asyn: false,
        data: "Action=" + actionId + additional,
        contentType: "string",
        error: function(xhr, status, errorThrown) {
            alert(errorThrown + '\n' + status + '\n' + xhr.statusText);
        },
        success: function(data) {
            alert(data);
            callback(data);
        }
    });
}

      

ASHx

context.Response.ContentType = "text/plain";
action = context.Request.QueryString["Action"];
switch ((ClientSideActionsRequest)Enum.Parse(typeof(ClientSideActionsRequest), action))
{
    case ClientSideActionsRequest.ShowProducts:
    long userId = WebCommon.CurrentlyWatchedUser.Id;
    List<UserItems> userItems = UserItems.GetByUserId(userId);
    string[] items = HtmlWrapper.WrapAsItems(userItems);
    if (items.Length > 0)
    {
         context.Response.Write(items.Aggregate((current, next) => string.Format("{0} , {1}", current, next)));
    }
    break;
}

      

Thanks!

+2


a source to share


2 answers


Can you be more specific? There could be several possible things that could be wrong: does browser caching or when debugging on the server show old values ​​for the session?



Make sure jQuery.ajax cache parameter is set to false. You can also see this question and answer regarding the aggressive nature of IE ajax caching.

+1


a source


You just use the cache parameter to false.

 $.ajax({ 
     url: "url",
     cache: false,
     ....

      



Sample script

+1


a source







All Articles