yodeski / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

Add support for Asp.net callback mechanism - used by Devexpress controls (and others) #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please add support for asp.net callbacks to enable automatic profiling of ajax 
callbacks.

This enables support for Devexpress controls and, although I haven't used 
Telerik controls, I suspect it'll solve the problem in issue 75 too. 
(http://code.google.com/p/mvc-mini-profiler/issues/detail?id=75)

You just need to override the WebForm_ExecuteCallback method which is called 
after each callback. See attached patch or code below.

        if (typeof (WebForm_ExecuteCallback) == "function") {
            WebForm_ExecuteCallback = (function (callbackObject) {
                // Store original function
                var original = WebForm_ExecuteCallback;

                return function (callbackObject) {
                    original(callbackObject);

                    var stringIds = callbackObject.xmlRequest.getResponseHeader('X-MiniProfiler-Ids');
                    if (stringIds) {
                        var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
                        MiniProfiler.fetchResultsExposed(ids);
                    }
                }

            })();
        }

Original issue reported on code.google.com by appleb...@gmail.com on 2 Sep 2011 at 10:03

Attachments:

GoogleCodeExporter commented 9 years ago
We already have 

 // fetch results after ASP Ajax calls
        if (typeof (Sys) != 'undefined' && typeof (Sys.WebForms) != 'undefined' && typeof (Sys.WebForms.PageRequestManager) != 'undefined') {
            // Get the instance of PageRequestManager.
            var PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();

            PageRequestManager.add_endRequest(function (sender, args) {
                if (args) {
                    var response = args.get_response();
                    if (response.get_responseAvailable() && response._xmlHttpRequest != null) {
                        var stringIds = args.get_response().getResponseHeader('X-MiniProfiler-Ids');
                        if (stringIds) {
                            var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
                            fetchResults(ids);
                        }
                    }
                }
            });
        }

do we need the above code as well? 

Original comment by sam.saff...@gmail.com on 14 Feb 2012 at 4:48

GoogleCodeExporter commented 9 years ago
Yes, the existing code doesn't catch partial page refreshes using Asp.Net 
callbacks (different to postbacks in an Updatepanel) which many/some of the 
component vendors seem to use. 

See http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx and 
http://www.devexpress.com/Support/Center/p/K18387.aspx for more info.

To be honest, I am no expert down in these depths of the asp.net ajax 
functionality, but I have been using the mini-profiler with my modification for 
some time now and it works well for catching DevExpress control callbacks. 

A bit of googling shows that Telerik also uses this mechanism, at least for 
some of its controls, and I suspect a few other vendors would too.

Original comment by geoff.ap...@4sightsport.com on 15 Feb 2012 at 9:26

GoogleCodeExporter commented 9 years ago
ok patched it ... let me know if it works.

Original comment by sam.saff...@gmail.com on 19 Feb 2012 at 11:47

GoogleCodeExporter commented 9 years ago
Great, thanks Sam.

I've just tested this and it works as expected.

Original comment by geoff.ap...@4sightsport.com on 20 Feb 2012 at 9:04