© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•5mo ago•
2 replies
TangoBee

How to capture request body in IIS managed module

Hi,
I'm trying to create an IIS server module that can capture all the incoming and outgoing traffic and send it to my backend server.
So, when I try to add the code below in my module and try to capture the request body, all the requests that contain a payload time out after 60 seconds. However, all the other requests that don't contain any payload work fine. If I remove the code below, then everything works fine, but I won't be able to capture the request body.


code to capture request body:
                using (var reader = new StreamReader(request.GetBufferedInputStream(), request.ContentEncoding))
                {
                    string requestBody = reader.ReadToEnd();
                    HttpContext.Current.Items["RequestPayload"] = requestBody;
                }
                using (var reader = new StreamReader(request.GetBufferedInputStream(), request.ContentEncoding))
                {
                    string requestBody = reader.ReadToEnd();
                    HttpContext.Current.Items["RequestPayload"] = requestBody;
                }



Full code: https://pastecord.com/beqynygimu.cs
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Body request
C#CC# / help
2y ago
Does Changing CLR version from V4 to No Managed Code in IIS has any effect on request?
C#CC# / help
4y ago
❔ how to get city data from request body?
C#CC# / help
3y ago