首页 > 编程语言 >.NET程序-配置使用Fidder代理,抓取后台HTTP请求

.NET程序-配置使用Fidder代理,抓取后台HTTP请求

时间:2023-07-07 10:46:01浏览次数:39  
标签:8888 方式 Fidder 代理 HTTP NET defaultProxy localhost

一般我们用Fidder查看浏览器的Http请求来分析页面的性能问题,但是如果是后台.Net发起Http请求怎么看?下面介绍一种方法,通过配置.NET程序,使用Fidder代理可以查看后台的HTTP请求。

首先开启Fiddler2代理:

 

下面有三种方式设置System.Net使用Fidder作为。

方式一:代码方式

var defaultProxy = new WebProxy();
defaultProxy.Address = new Uri("http://localhost:8888");
defaultProxy.Credentials = new NetworkCredential("xxxxx", "********");
System.Net.WebRequest.DefaultWebProxy = defaultProxy;

方式二:配置文件

  <system.net>
    <defaultProxy useDefaultCredentials="True">
      <proxy proxyaddress="http://localhost:8888" bypassonlocal="True"/>
    </defaultProxy>
  </system.net>

方式三:配置文件+IE代理

 <system.net>
    <defaultProxy useDefaultCredentials="True">
      <proxy bypassonlocal="True" usesystemdefault="True"/>
    </defaultProxy>
  </system.net>

注意:

方式二、三要修改Web.config,会自动回收应程序池,如果不想回收建议采用方式一:

方式一操作步骤如下

Net4.0方式:新建文件名称“SetProxy.cshtml”,将以下内容复制进去,再将文件拷贝到对应的(根)站点下。

@using System.Net;
@{
    string ip = Request.QueryString["i"];//设置Filddler远程代理
    string port = Request.QueryString["p"];//设置Filddler远程代理 8888
    if (ip.Length <= 1)
    {
        port = "8888";
    }
    var defaultProxy = new WebProxy();
    if (!string.IsNullOrEmpty(ip))
    {
        defaultProxy.Address = new Uri("http://" + ip + ":" +  port);
        defaultProxy.UseDefaultCredentials = false;
        //defaultProxy.Credentials = new NetworkCredential("xxxxx", "********");
    }
    System.Net.WebRequest.DefaultWebProxy = defaultProxy;
}
<p>代理地址=@(defaultProxy.Address)</p>

Net2.0方式:新建文件名称“SetProxy.aspx”,将以下内容复制进去,再将文件拷贝到对应的(根)站点下(net2.0)。

<%@ Page Language="C#" EnableSessionState="false" Inherits="System.Web.UI.Page" %>
<%@ Import Namespace="System.Net" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script runat="server">
    protected override void onl oad(EventArgs e)
    {
        base.OnLoad(e);
        string ip = Request.QueryString["i"];//设置Filddler远程代理 http://10.20.60.82:8888
        string port = Request.QueryString["p"];//设置Filddler远程代理 8888
        if (ip.Length <= 1)
        {
            port = "8888";
        }
        WebProxy defaultProxy = new WebProxy();
        if (!string.IsNullOrEmpty(ip))
        {
            defaultProxy.Address = new Uri("http://" + ip + ":" + port);
            defaultProxy.UseDefaultCredentials = false;
            //defaultProxy.Credentials = new NetworkCredential("xxxxx", "********");
        }
        System.Net.WebRequest.DefaultWebProxy = defaultProxy;
        Response.Write("代理地址=" + defaultProxy.Address);
        Response.ContentType = "text/html";

    }
</script>
</head>
</html>

设置代理-浏览器访问页面:

设置为本地Fiddler代理地址 localhost:2010/SetProxy.cshtml?i=localhost&p=8888

注:使用完成后,务必清空代理

 清空代理:localhost:2010/SetProxy.cshtml?i=

 

标签:8888,方式,Fidder,代理,HTTP,NET,defaultProxy,localhost
From: https://www.cnblogs.com/zquick/p/17533997.html

相关文章

  • Multi-Modal Attention Network Learning for Semantic Source Code Retrieval 解读
    Multi-ModalAttentionNetworkLearningfor SemanticSourceCodeRetrieva Multi-ModalAttentionNetworkLearningfor SemanticSourceCodeRetrieval,题目意思是用于语义源代码检索的多模态注意网络学习,2019年发表于ASE的##研究什么东西Background:研究代码检索技......
  • HTTP协议
    HTTP协议【1】http协议基础http协议,我们分三部分学习:协议基础(基本概念、协议特点、协议格式、相关工具使用)django框架的时候,学习http协议的web服务器Linux阶段的时候,学习http协议的剩余内容(http服务器的搭建、http服务器提供的网络服务、http协议相关配置、https协议使用)......
  • 记powerjob依赖的netty版本问题
    1.在使用powerjob的时候,启动项目有报netty相关ClassNotFoundException的问题<dependency><groupId>tech.powerjob</groupId><artifactId>powerjob-client</artifactId><version>4.3.1</version>......
  • IDEA:AXIOS使用网页报错net::ERR_CONNECTION_REFUSED
     之前使用的是下载的文件,一直是报错的状态,页面加载不进来 之后进官网选择在线的之后可用。......
  • 01.net6集成redis
    安装redis自己使用dockercompose安装redis,yml文件如下:version:'3.9'services:redis:image:redis:6.2.5container_name:docker_redisprivileged:truevolumes:-./data:/data-./conf/redis.conf:/usr/local/etc/redis/redis.conf......
  • 阿里区块链开放联盟使用http方式对接
    using(HttpClienthttpClient=newHttpClient()){/*所有的步骤实例都得进行http请求,当前demo中我的请求放在最后,只是一步一步的流程进行开发*/SendEntityentity=newSendEntity();#region步骤一:调用合约接口,将数据上链操作成功实现合约调用的列子(目前注释......
  • 2. HTML 进阶之HTTP请求
    1)请求组成请求由三部分组成请求行请求头请求体可以用telnet程序测试2)请求方式与数据格式get请求示例GET/test2?name=%E5%BC%A0&age=20HTTP/1.1Host:localhost%E5%BC%A0是【张】经过URL编码后的结果post请求示例POST/test2HTTP/1.1Host:localho......
  • java http大文件断点续传上传问题
    ​ 这里只写后端的代码,基本的思想就是,前端将文件分片,然后每次访问上传接口的时候,向后端传入参数:当前为第几块文件,和分片总数下面直接贴代码吧,一些难懂的我大部分都加上注释了:上传文件实体类:看得出来,实体类中已经有很多我们需要的功能了,还有实用的属性。如MD5秒传的信息。pub......
  • java中http请求-okhttp使用连接池优化
    愿历尽千帆,归来仍是少年原因:避免频繁频繁的开关连接。1.Maven添加依赖<dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>3.10.0</version></dependency>2.OkHttpConfiguration配置类......
  • 网络填坑之路(7)使用netsh获取WiFi密码
    netsh简介netsh:全称NetworkShell是一个windows系统本身提供的功能强大的网络配置命令行工具Netsh是命令行脚本实用工具它允许从本地或远程显示或修改当前正在运行的计算机的网络配置netsh可以获取计算机曾经连接过的所有WiFi信息以及WiFi的明文密码获取密码步骤1、进入ne......