This article is a mirror article of machine translation, please click here to jump to the original article.

View: 218922|Reply: 50

[Source] .NET/C# Developing Fiddler Tutorial [with Source Code]

[Copy link]
Posted on 9/29/2018 11:15:56 AM | | | |
Fiddler version:

Progress Telerik Fiddler Web Debugger
v5.0.20182.28034 for .NET 4.6.1
Built: 2018年6月27日



1: First, we use vs2017 to create a new .NET 4.0 library project (This is wrong, as I will say below, you need to build a 4.6.1 project, otherwise the compilation will fail), as shown below:



Since my fiddler version is relatively high, the requirements for the .NET version will be higher, and the error will be reported as follows when compiling and generating the .NET 4.0 version:

1>------ All rebuild has been started: Project: fiddler-plugin-demo, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3274: Failed to resolve the main reference "Fiddler" because it was targeted at ". NETFramework, Version=v4.6.1". This framework version is higher than the current target framework". NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3268: Failed to resolve the main reference "Fiddler", Because it has an indirect dependency on the framework assembly "System.Net.Http, version=4.0.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", which fails to be parsed in the current target framework. “. NETFramework,Version=v4.0”。 To resolve this issue, remove the reference to "Fiddler" or redirect the target of the application to the framework version that contains "System.Net.Http, version=4.0.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly analytics, version=1.0.20182.27266, culture=neutral, PublicKeyToken=2b2cea67609c9510 "has indirect dependencies, and the assembly is directed at ". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly newtonsoft.json, version=11.0.0.0, culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"has indirect dependencies, and the assembly is directed against ". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly GA. analytics.monitor, version=1.0.20182.27266, culture=neutral, PublicKeyToken=2b2cea67609c9510 "has an indirect dependency that the assembly is related to". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\Properties\AssemblyInfo.cs(37,12,37,19): error CS0246: Failed to find type or namespace name" Fiddler" (is there a missing using instruction or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(1,7,1,14): error CS0246: Failed to find type or namespace name "Fiddler" (missing using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(10,34,10,45): error CS0246: Failed to find type or namespace name "IAutoTamper" ( Is there a missing using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(19,44,19,51): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(24,45,24,52): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(29,45,29,52): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(34,46,34,53): error CS0246: Failed to find type or namespace name "Session" (missing.) using directive or assembly reference?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\DemoExtention.cs(39,44,39,51): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?)
========== Regenerate all: 0 succeeds, 1 fails, and 0 ========== skipped



The solution is to change to .NET 4.6.1!

2: Add the fiddler.exe reference in Solution Explorer, my fiddler installation directory is: C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler, as shown below:



3: Set the minimum version of fiddler that the plugin is running

Add the Fiddler.RequiredVersion attribute to your project's AssemblyInfo.cs (and anywhere else in your code) file.



4: Create a new Fiddler tab UI control

You need to add a reference to the System.Windows.Forms assembly

Start by adding a user control to your project named TestControl.cs (arbitrary), as shown in the image below:



Then place a random Button control on top of the user control and write a simple line of click event code:



5: Create a new DemoExtention extension class

DemoExtention class inherits the IAutoTamper interface,The IAutoTamper interface inherits the IFiddlerExtension interfaceAll plugins that implement the IAutoTamper interface will be called on every http/https request or response, so they can be used to hijack or modify http/https request response data.

Note: The method of this interface is called in the background, non-UI thread, if you want to update the UI, you can use the Invoke or BeginInvoke method to update the UI. All methods of IAutoTamper may be executed before the OnLoad event.

The code is as follows:



6: Fiddler loads the plugin

After we program and generate, copy the two files fiddler-plugin-demo.dll and fiddler-plugin-demo.pdb under the Debug directory to the scrip{filter}ts folder of our fiddler installation directory.

My own is: C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler\scrip{filter}ts folder



Finally, we restart and open Fiddler, and we can see our controls on the tab, as shown below:



7: Enable the plugin to be automatically deployed to the fiddler plugin directory

Every time we modify the plugin, we need to copy the dll to the scrip{filter}ts folder again, we can solve this problem by the VS generation event, we recompile the generation, VS will automatically copy our dll to the scrip{filter}ts directory, and fill in the following command in the later generation event command line:




As shown below:



Tested for normal use.

Finally, attach the source code:

Tourists, if you want to see the hidden content of this post, pleaseReply





Previous:HLML instructional videos
Next:Very developed developed Guo Degang's
 Landlord| Posted on 9/30/2018 9:22:48 PM |
Enable the Fiddler Debug function

1. Enable the debug function in the fiddler command-line tool


2. Display error and exception information

prefs set fiddler.debug.extensions.showerrors True

3. Display log information

prefs set fiddler.debug.extensions.verbose True

After turning on log display, the log information output by the developer is displayed in the log tab interface on the right side of Fiddler.
Posted on 5/12/2024 10:29:06 PM |
Study, learn
 Landlord| Posted on 12/5/2020 9:46:47 PM |
urlreplace id.itsvse.com id.test.itsvse.com
Redirect commands
Posted on 9/29/2018 3:57:45 PM |
This is very essential, good! Come and learn and worship!
Posted on 9/29/2018 5:10:56 PM |
This is good, come and learn
Posted on 9/30/2018 12:48:21 AM |
Thank you for sharing
Posted on 9/30/2018 10:09:25 AM |
Thanks for sharing
Posted on 9/30/2018 11:56:38 PM |
Not bad, not bad...
Posted on 10/1/2018 4:51:24 PM |
Come and learn and worship!
Posted on 11/30/2018 12:28:53 PM |
45333333333344444444444444444
Posted on 12/1/2018 2:44:20 PM |
Check out how this code goes
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com