C
C#3w ago
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
2 Replies
wasabi
wasabi3w ago
I don't know why it would time out, but it's clearly a potential DoS, or other error causing path.
Daiko Games
Daiko Games3w ago
I am sorry i clicked on accident i don´t know any of that topic

Did you find this page helpful?