我的問題是有點複雜: 我寫在C#,asp.net和使用jqueryInternet Explorer中的ashx文件的問題
- 我有一個使用jQuery的AJAX 方法將請求發送到 服務器頁面。
- 我有一個ashx文件(處理程序)到 迴應這些請求。
- 用戶可以在 多個頁面上執行多項更改,然後使用一些方法 ,這些方法將調用ajax方法。
- 我的ashx文件從 會話變量中讀取一些值並相應地執行 。
這適用於所有瀏覽器,但在Internet Explorer中正常工作。 在Internet Explorer中,會話似乎保存舊信息(舊用戶ID)。這是令人難以置信的,相同的代碼在Firefox,鉻和Safari瀏覽器中工作正常,但與ie失敗。
什麼可能導致它?我不知道哪裏可以開始尋找解決方案。
btw,對不起,一般的標題,無法弄清楚如何用幾句話來解釋。
這裏是jQuery代碼和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;
}
謝謝!
你能粘貼的背後與此問題相關的重要的ashx的代碼? – 2010-04-13 20:17:52