我在 MVC 4 应用程序上使用 MiniProfiler。我们有一个以模式呈现的 View (使用 Colorbox jquery 插件)。然后该 View 中有一个局部 View ,其中包含一个 ajax 形式,如下所示:

@using(Ajax.BeginForm("<action name>", "<controller name>", new {area="<area name>"}, new AjaxOptions 
    { 
        UpdateTargetId = "modal-body", 
        InsertionMode = InsertionMode.Replace, 
        HttpMethod = "POST" 
    })) 
{ 
    <html for form here> 
} 

当我们提交表单时,它返回相同的部分 View 以覆盖 View 上的整个部分。当它发布时 MiniProfiler 抛出一个错误: SyntaxError: Unexpected token ,

这发生在这个函数中:
var jQueryAjaxComplete = function (e, xhr, settings) { 
            if (xhr) { 
                // should be an array of strings, e.g. ["008c4813-9bd7-443d-9376-9441ec4d6a8c","16ff377b-8b9c-4c20-a7b5-97cd9fa7eea7"] 
                var stringIds = xhr.getResponseHeader('X-MiniProfiler-Ids'); 
                if (stringIds) { 
                    var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds); 
                    fetchResults(ids); 
                } 
            } 
        }; 

它期待一个 json 的 guid 数组,但它获得了两次数组,如下所示:

“[” 6de0e02c-e694-4d8a-AC22-ea6a847efe0e “”970f6640-fe5b-45d9-bf59-c916b665458d“],[ ”6de0e02c-e694-4d8a-AC22-ea6a847efe0e“,” 970f6640-fe5b-45d9-bf59-c916b665458d “]”

这会导致它在尝试解析数组时呕吐。我不确定为什么数组会重复。任何帮助将不胜感激。谢谢!

请您参考如下方法:

这是一个 miniprofiler 错误 https://github.com/MiniProfiler/ui/pull/5

等待下次更新。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!