Tom*_*Tom 4 extjs servicestack mvc-mini-profiler
所以,在我的Index.cshtml
页面中,当我最初加载页面时,我有:
@inherits ViewPage
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="app.ext.js"></script>
<script type="text/javascript" src="dump.js"></script>
@ServiceStack.MiniProfiler.Profiler.RenderIncludes().AsRaw()
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
好的,我可以看到它的分析索引,一堆ExtJS,以及服务器端的第一个ajax调用我的ServiceStack(在/ api/session中).
现在,在我的ExtJS表单中,当我点击它时,我有一个Customers选项卡发送ajax请求,/api/customers
当我点击它时,我有一个标签/api/orders
.
但是,当我开始点击,比如客户选项卡时,Miniprofiler不再将任何后续的ajax请求添加到列表中?我以为Miniprofiler可以记录ajax请求没什么特别需要做的吗?为什么不为我记录后续的ajax请求?我错过了什么?
我知道这有点旧,但如果有人有兴趣使用miniprofiler with angularjs的实现如下:
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push(["$q", function ($q) {
return {
'response': function (response) {
if (typeof (MiniProfiler) != 'undefined' && response.config.url.indexOf(".html") < 0) {
var stringIds = response.headers('X-MiniProfiler-Ids');
if (stringIds) {
MiniProfiler.fetchResultsExposed(angular.fromJson(stringIds));
}
}
return response || $q.when(response);
}
};
}]);
}]);
Run Code Online (Sandbox Code Playgroud)
Nuget提供的当前版本不支持拦截ExtJS ajax调用.似乎有一个针对该功能的拉取请求,但它尚不可用.
以下是我必须做的事情:
Ext.require('Ext.Ajax');
Ext.onReady(function () {
Ext.Ajax.on('requestcomplete', function (e, xhr, settings) {
if (typeof (MiniProfiler) != 'undefined') {
var stringIds = xhr.getResponseHeader('X-MiniProfiler-Ids');
if (stringIds) {
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
MiniProfiler.fetchResultsExposed(ids);
}
}
});
});
Run Code Online (Sandbox Code Playgroud)