开发者

Mvc Mini Profiler + ASP.NET PageMethods not updating

开发者 https://www.devze.com 2023-03-25 20:36 出处:网络
I\'m using the awesome MVC Mini Profiler and am trying to profile some PageMethods. The problem is the results are only displayed upon page reload.

I'm using the awesome MVC Mini Profiler and am trying to profile some PageMethods. The problem is the results are only displayed upon page reload.

On the PageMethods response header i can see a buildup of 'X-MiniProfiler-Ids' Ids, which means the Profiler is doing it's thing, now I want to see those results without reloading the page.

One solution would be to access the response header of the PageMethod itself, as explained here. This did not work at all.In var req = PageMethods.DoWork(cal开发者_运维技巧lback);, req ends up as undefined.

I also tried creating a new PageMethod (HttpContext.Current.Response.Headers["X-MiniProfiler-Ids"]) to return the response header, but as I imagined, it did not work as the response header is not fully built yet (I imagine).

What I want to do is find a way to either get the IDs of the profiler sessions from the header, or get the Mini Profiler do it's thing without reloading the page any other way.


Ok, I got it working, i tossed away asp.net default PageMethods completly and am using solely jquery ajax instead. With the above i can do pretty much the same as the asp.net PageMethods without the ScriptManager overhead

function PageMethod(UrlMethod, callback) {
    return $.ajax({
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: '{}',
        dataType: 'json',
        url: UrlMethod,
        success: function (result, status, xhr) {
            FetchProfilerResults(xhr.getResponseHeader("X-MiniProfiler-Ids"));
            callback(result.d);
        }
    });
}

the FetchProfilerResults just grabs and parses the miniProfiler IDS and calls MiniProfiler.fetchResultsExposed(ids); from the miniprofiler javascript includes and everything is working happily

0

精彩评论

暂无评论...
验证码 换一张
取 消