惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
T
Threatpost
G
Google Developers Blog
T
Threat Research - Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Exploit Database - CXSecurity.com
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Schneier on Security
B
Blog
V2EX - 技术
V2EX - 技术
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
Schneier on Security
Schneier on Security
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
S
Security @ Cisco Blogs
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
Project Zero
Project Zero
I
Intezer
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler

博客园 - Gary Zhang

Human-in-the-Loop (HITL) 设计文档-学习笔记 MiniMind 从零训练 LLM — 详细学习笔记 C端产品的三个关键词和B端产品的一个关键词 人工智能相关概念 经济活动原理推导 使用Matlab对账期客户订单的逾期率进行预测 BizTalk RosettaNet 解决方案 - Gary BizTalk Visual Studio 各版本自动部署GAC命令 RosettaNet PIP 清单 BizTalk RosettaNet解决方案与项目调研 ChatGPT可能的影响与机会 使用Google Bigquery快速用SQL查询Excel数据 Azure logic App 构建低成本EDI解决方案(英文) 从 BizTalk 跟踪数据库中清除数据 自助批量下载Confluence文档内容 Elsa 工作流引擎 Hello World Azure 升级订阅服务及服务区别 MIME 消息 BizTalk性能优化配置(建议) Azure Logic APP 与 EDIFACT/X12/RosettaNet/AS2解决方案概述 BizTalk 安装管理 API
存储HTTP请求Body部分到文件中
Gary Zhang · 2023-12-14 · via 博客园 - Gary Zhang

代码

using System;
using System.IO;
using System.Web;

public class RequestLoggerModule : IHttpModule
{
    private const string LogFolderPath = @"C:\Gary\Log\"; // 替换为实际的日志文件夹路径

    public void Init(HttpApplication context)
    {
        context.BeginRequest += OnBeginRequest;
    }

    public void Dispose()
    {
    }

    private void OnBeginRequest(object sender, EventArgs e)
    {
        HttpApplication application = (HttpApplication)sender;
        HttpRequest request = application.Context.Request;

        // 读取请求内容
        using (StreamReader reader = new StreamReader(request.InputStream))
        {
            string requestBody = reader.ReadToEnd();

            // 在这里,将请求内容写入到文件
            LogRequest(requestBody);
        }
    }

    private void LogRequest(string content)
    {
        // 构造日志文件路径
        string logFilePath = Path.Combine(LogFolderPath, $"RequestLog_{DateTime.Now:yyyyMMdd_HHmmssfff}.txt");

        // 写入请求内容到文件
        File.WriteAllText(logFilePath, content);
    }
}

IIS配置

需要将DLL文件拷贝到网站文件目录的bin文件夹下面

	  <httpModules>
		  <add name="RequestLoggerModule" type="RequestLoggerModule" />
	  </httpModules>