1

I am writing a control that will warn a user that their session is about to timeout. I can easily track standard postbacks and post packs in update panels, but I'm struggling to see how I can track calls made to any / all web services.

Is there a mechanism for this, or will I have to try and override the Sys.Net.WebRequest invoke code?

2 Answers 2

1

There's nothing wrong in replacing the Sys.Net.WebRequest code - just keep a reference to the previous implementation and call it, after tracking the call. Something like this should do the trick:

(function() {
    var originalWebRequest = Sys.Net.WebRequest;
    Sys.Net.WebRequest = function() {
        // track call
        //...

        // call original WebRequest
        return originalWebRequest.apply(this, arguments);
    }
})();
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this approach and what I'm finding is the functions (e.g. get_headers) are no longer part of the object. Is this because apply also need to apply something additional?
0

In a similar requirement, we wrote a HttpModule. At that point you could have a good control over your request and track your postbacks of webservices. See here for more information about how to write your own httpmodule http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.