Jquery 使用jqgrid时,如何在使用Internet Explorer时强制从服务器刷新editform中的下拉列表?

Jquery 使用jqgrid时,如何在使用Internet Explorer时强制从服务器刷新editform中的下拉列表?,jquery,asp.net-mvc,jqgrid,data-url,Jquery,Asp.net Mvc,Jqgrid,Data Url,我有一个asp.net-mvc站点,Iam正在使用,我有几个字段的编辑控件是下拉列表。我有一个问题,下拉列表所依赖的名称int来自另一列,因此每当我打开编辑表单时,或者如果我单击“+”添加新条目以确保显示正确的字符串,我需要强制服务器刷新 我看到一个问题,Internet Explorer似乎在缓存我的下拉列表,即使我尽力告诉它不要。我没有在Firefox或Chrome中观察到这个问题 这是我的密码: 我正在观察问题的Col模型行: { name: "SiteSettings", in

我有一个asp.net-mvc站点,Iam正在使用,我有几个字段的编辑控件是下拉列表。我有一个问题,下拉列表所依赖的名称int来自另一列,因此每当我打开编辑表单时,或者如果我单击“+”添加新条目以确保显示正确的字符串,我需要强制服务器刷新

我看到一个问题,Internet Explorer似乎在缓存我的下拉列表,即使我尽力告诉它不要。我没有在Firefox或Chrome中观察到这个问题

这是我的密码:

我正在观察问题的Col模型行:

     { name: "SiteSettings", index: "SiteSettings", width: 250, editable: true, 
      edittype: "select", editoptions: { dataUrl: "/SiteSettings/GetSelectData" }, 
      editrules: { edithidden: true, required: false} },
下面是构建编辑按钮和添加按钮的代码

    onClickButton: function () {
        jQuery("#grid").jqGrid('editGridRow', "new", { recreateForm: true, url: '/MyController/Add', afterSubmit: function (response, postdata) {
            var responseJson = $.parseJSON(response.responseText);
            return HandleJqGridAddResponse(responseJson);
        }, height: 380, width: "auto", closeAfterAdd: true, reloadAfterSubmit: true
        });
    },

        jQuery("#grid").jqGrid('editGridRow', id,
                    { url: '/MyController/Update', afterSubmit: function (response, postdata) {
                        var responseJson = $.parseJSON(response.responseText);
                        return HandleJqGridResponse(responseJson);
                    },
                        height: 380, width: "auto", recreateForm: true, closeAfterEdit: true,
                        closeOnEscape: true, reloadAfterSubmit: true
                    });
我想

  recreateForm: true

这会起作用,但似乎没什么区别

但我注意到,当我打开编辑表单或新表单时,后端上的函数没有被调用来返回下拉列表中的项目列表,因此必须有一些客户端缓存

如何在每次尝试编辑或添加新条目时强制刷新dataurl(dataurl:“/SiteSettings/GetSelectData”)应该在客户端为您工作


为了确保服务器端和客户端都没有缓存,您可以使用
[OutputCache(NoStore=true)]
属性修饰检索数据的操作
我认为bast方法是在处理
数据URL的代码中的服务器端设置相应的HTTP头(
“/SiteSettings/GetSelectData”
)。我个人会包括这一行

HttpContext.Current.Response.Cache.SetMaxAge (new TimeSpan (0));

作为
GetSelectData
操作的第一行。它将设置
缓存控制:private,max age=0
标题(请参阅),并且您将确保没有web浏览器或web代理缓存服务器响应

如果您更喜欢缓存选项的声明性设置,可以使用

[OutputCache(Duration = 0)]


我不确定哪些设置是最好的,但目标是设置
缓存控制:private,max age=0
标题。

您的重新创建表单行与我已有的表单行有何不同?Ie以缓存此类请求而闻名。在mvc控制器中的操作上添加[OutputCache(duration=0)]。这会强制Ie刷新
Response.Cache.SetCacheability (HttpCacheability.ServerAndPrivate);
Response.Cache.SetMaxAge (new TimeSpan (0));
[OutputCache(Duration = 0)]
[OutputCache(Duration = 0, Location = OutputCacheLocation.Client, VaryByParam = "*")]