|
||||||||
| ||||||||
|
Please note: The FiddlerAPI is still under construction, and future releases may require changes to your code. Thanks for your patience. Extending Fiddler with .NET CodeIntroductionFiddler2 is a highly versatile platform that offers extensibility via both script and .NET code. Using the extensibility mechanisms, you can add to Fiddler's UI, automatically modify requests or responses, and custom Inspectors that enable scenario-specific display and manual-modification of requests and responses. PrerequisitesWriting extensions for Fiddler2 requires Visual Studio .NET 2005 or the free .NET Framework v2 command-line compilers. You will also need to have the most recent version of Fiddler2 installed in order to develop Fiddler extensions. If you've previously developed Fiddler extensions, you may want to read the article Updating Fiddler Extensions for v2.1. Direct Fiddler2 to load your extension assembliesFiddler loads extension assembly DLLs from the %Program Files%\Fiddler2\Scripts and %USERPROFILE%\My Documents\Fiddler2\Scripts folders. Install to the %Program Files% location to make your extensions available to all users on the machine, or the %UserProfile% folder to make the extension available only to the current user. In addition to placing your extension DLLs in the appropriate folder, you must also mark your assembly to indicate the minimum version of Fiddler required for your Assembly to load correctly. Set the Fiddler.RequiredVersion attribute in your AssemblyInfo.cs file (or elsewhere in your code), as follows:
If Fiddler finds a RequiredVersion attribute that indicates a later version of Fiddler is required, the user will be notified that a later version of Fiddler is required to use your extension. Assemblies which do not contain a RequiredVersion attribute are silently ignored. The IFiddlerExtension InterfacePublic classes in your assembly that implement the IFiddlerExtension interface will be loaded by Fiddler during startup.
The OnLoad function will be called when Fiddler has finished loading and its
UI is fully available. At this point, you can safely add menu items,
tabbed pages, or other elements to the Fiddler UI. The IAutoTamper InterfaceExtensions that implement the IAutoTamper interface (which descends from the IFiddlerExtension interface) are called for each HTTP/HTTPS request and response, enabling modifications, logging, or other operations.
The IHandleExecAction InterfaceExtensions that implement the IHandleExecAction interface are called when the user has entered a command into the QuickExec box. If your extension would like to react to the command (and prevent further processing by other extensions and Fiddler itself) return true from this method.
Note that the Fiddler.Utilities class includes a helper function which you
may find useful when interpreting the sCommand parameter.
Here's a trivial extension which modifies the User-Agent string of all
outbound requests.
using System; Adding an Icon to your Extension's tabThe icons are chosen from the ImageList named imglSessionIcons attached to FiddlerApplication.UI. In order to use an existing icon, you can simply set the .ImageIndex property as follows: public void OnLoad() oView = new TimelineView(); oPage.Controls.Add(oView); oView.Dock = DockStyle.Fill; FiddlerApplication.UI.tabsViews.TabPages.Add(oPage); } If you want to add your own custom image, you'll first have to add it to imglSessionIcons. This member was non-public in older versions of Fiddler, so you will get a visibility exception in older versions if you attempt to manipulate imglSessionIcons. To deal with this you could either: 1> Just reuse an existing icon via the ImageIndex property, or 2> Use the [assembly: Fiddler.RequiredVersion("2.1.3.1")] attribute to require that users upgrade to a current version of Fiddler.Other Examples and Information
Almost done...
If you need help or have questions, please email me using the Contact link above. Change Log ©2008 Microsoft Corporation |