Fiddlercore Sessionlist

Unlike Fiddler, FiddlerCore does not keep a session list automatically. If you want a session list, simply create an List<Fiddler.Session> and add new sessions to it as they’re received. Note that the multi-threaded nature of FiddlerCore means you need to Invoke to a single thread, use thread-safe data structures, or use a Monitor or other synchronization mechanism (as shown below) to update/iterate a list of sessions in a thread-safe way.

// Inside your main object, create a list to hold the sessions
// This generic list type requires your source file includes #using System.Collections.Generic.
    List<Fiddler.Session> oAllSessions = new List<Fiddler.Session>();
// Inside your attached event handlers, add the session to the list:
    Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS) {

Keep in mind, however, that keeping a session list can quickly balloon out the memory use within your application because a web Session object will not be garbage collected while there's an active reference to it (in the oAllSessions list). You should periodically trim the list to keep it of a reasonable size. Alternatively, if you only care about request URLs or headers, you could keep a List<> of those types rather than storing a reference to the full session object.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License