|
||||||||
|
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. Fiddler v2.x loads only .NET CLR v2.0 assemblies; use Visual Studio 2005+ to compile your extension. If you use Visual Studio 2010 or later, you must change your project to target the .NET2.0/3.5 framework or Fiddler will not load your extension. Fiddler itself requires only that the user have .NET Framework 2.0 SP1 installed. You may have your extensions target the .NET Framework 3.5 (which includes Linq) since that framework also (confusingly) runs on the v2.0 CLR but you MUST yourself ensure that the user has the required Framework version installed BEFORE you install your extension, or a user with only the older Framework will crash on boot. You should also ensure your project targets AnyCPU to ensure that it works properly with 64bit Fiddler. You should use only the most recent version of Fiddler2 installed in order to develop Fiddler extensions. Learn more about Building assemblies to run in both Fiddler v2 and v4. Debugging your Extensions
If you write to me complaining that your extension doesn't work and you have not first set these preferences before testing, I will tease you mercilessly. Direct Fiddler 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 Interface (extends IFiddlerExtension)Extensions 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 IAutoTamper2 Interface (Extends IAutoTamper) ///
<summary> The IAutoTamper3 Interface (Extends IAutoTamper2)/// <summary> 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.3.5.0")] 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 ©2018 Eric Lawrence |