MVC是否有可能在某个地方缓存我的数据?

时间:2012-04-29 04:18:10

标签: asp.net-mvc asp.net-mvc-3

我有以下控制器操作:

public ActionResult Details(string pk)
        {
            IEnumerable<ContentDetail> model = null;
            try
            {
                model = _content.Details(pk);
                if (model.Count() > 0)
                {
                    return PartialView(getView(pk) + "Details", model);
                }
            }
            catch (Exception e)
            {
                log(e);
            }
            return Content("No records found");
        }

我用以下例程调用它:

$.ajax({
        cache: false,
        url: "/Administration/" + table + "s/Details",
        data: { pk: partitionKey },
        dataType: 'html',
        success: function (responseText) {
            $('#detailData').html(responseText);
            $(".updatable")
                .change(function (e) {
                    var type = $(this).attr('id').split('_')[0];
                    updateField(table, $(this), type);
                });
            $('.dialogLink')
                .click(function () {
                    dialogClick(this);
                    return false;
                });
        },
        error: function (ajaxContext) {
            ajaxOnFailure(ajaxContext)
        }
    });

我注意到有时当我在控制器动作的第一行放置一个断点时,它似乎并没有停在断点处。是否有可能MVC缓存结果,我怎样才能在调试时阻止这种情况发生?

2 个答案:

答案 0 :(得分:0)

检查控制器本身上是否设置OutputCache的任何变化,或者如果存在,则检查所有控制器可能继承的基本控制器。

我也注意到IE喜欢缓存内容并发现缓解这种情况的唯一方法是对开发人员窗口进行清理并清除缓存(或 ctrl + shift + 德尔

尝试将cache:false添加到.ajax调用中,看看是否有任何影响(jQuery会附加一个时间戳变量,使每个调用都唯一)。没关系,只是注意到了你把它包括在内。在这里一定要迟到 - 当我想念这样的事情时,一定要记下睡觉时间。

答案 1 :(得分:0)

加载fiddler并查看请求是否甚至从浏览器返回。理想情况下,您希望我通过此处提到的众多方法之一写出没有缓存标头 Disable browser cache for entire ASP.NET website