gpt4 book ai didi

c# - Internet Explorer ashx 文件问题

转载 作者:太空宇宙 更新时间:2023-11-03 11:48:50 25 4
gpt4 key购买 nike

我的问题有点复杂:我正在用 c#、asp.net 编写并使用 jquery

  1. 我有一个页面发送请求到服务器使用 jquery 的 ajax方法。
  2. 我有一个 ashx 文件(处理程序)响应这些请求。
  3. 用户可以对几个页面,然后使用一些方法这将调用 ajax 方法。
  4. 我的 ashx 文件从 session 变量和行为相应地。

这在所有浏览器中都能正常工作,但在 Internet Explorer 中除外。在 Internet Explorer 中, session 似乎包含旧信息(旧用户 ID)。令人难以置信,相同的代码在 Firefox、Chrome 和 Safari 中运行良好,但在 IE 中却失败了。

可能是什么原因造成的?我什至不知道从哪里开始寻找解决方案。

顺便说一句,对不起,标题一般,无法用几句话来解释。

这里是 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);
}
});
}

阿什克斯

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

谢谢!

最佳答案

能具体点吗?这里有一些可能出错的地方 - 它是在浏览器上缓存,还是在服务器上调试时,它是否显示 Session 的旧值?

确保将 jQuery .ajax 调用的缓存选项设置为 false。您可能还想查看 this question and answer关于 IE 的 ajax 缓存的侵略性。

关于c# - Internet Explorer ashx 文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2632863/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com