views:

310

answers:

1

My problem is a bit complicated: I am writing in c#, asp.net and using jquery

  1. I have a page that sends requests to the server using jquery's ajax method.
  2. I have a ashx file (handler) to respond to these request.
  3. User can perform several changes on several pages, then use some method that will call the ajax method.
  4. My ashx file reads some values From the session variables and acts accordingly.

This works fine in all browsers but in internet explorer. In internet explorer the session seems to hold old information (old user ids'). It's incredible, the same code works fine in firefox, chrome and safari but fails with ie.

What could be causing it? I have no clue where to even start looking for a solution.

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

Here are the jquery code and the ashx:

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;
}

Thank You!

+1  A: 

Can you be more specific? There's a few possible things that could be going wrong here - is it caching on the browser, or when you debug on the server, is it showing old values for Session?

Make sure you're setting the cache option of your jQuery .ajax call to false. You may also want to see this question and answer regarding the aggressive nature of IE's ajax caching.

womp
@womp. thank you. You just saved me so much time. Truely thank you so much :)
vondip