Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:05:40+00:00 2026-05-11T19:05:40+00:00

I have a WCF Service hosted in IIS/ASP.NET that accepts HTTP Post ( not

  • 0

I have a WCF Service hosted in IIS/ASP.NET that accepts HTTP Post (not form post) of serialized objects.

If the client sends malformed requests (eg they’re not serializing the object correctly) I’d like to log the message sent up.

We’re already using ELMAH to capture unhandled exceptions, so simply attaching the post data would be the easiest option.

I can get the current HttpContext during an exception, however this does only contains the HTTP Header information.

My question is this: Is there some way of capturing the original HTTP POST request body? Or, failing that – a better way (without a reverse proxy) of capturing the input that caused the error?

Edit: Just to clarify, running packet-level capturing at all times isn’t really suitable. I’m after a solution that I can deploy to Production servers, and which will have clients outside our control or ability to monitor.

Edit #2: A suggestion was made to access the Request.InputStream – this doesn’t work if you’re trying to read after WCF has read the request off the stream.

A sample piece of code to see how I’ve tried using this is here.

        StringBuilder log = new StringBuilder();

        var request = HttpContext.Current.Request;

        if (request.InputStream != null)
        {
            log.AppendLine(string.Format("request.InputStream.Position = \"{0}\"", request.InputStream.Position));
            if (request.InputStream.Position != 0)
            {
                request.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
            }

            using (StreamReader sr = new StreamReader(request.InputStream))
            {
                log.AppendLine(string.Format("Original Input: \"{0}\"", sr.ReadToEnd()));
            }
        }
        else
        {
            log.AppendLine("request.Inputstream = null");
        }


        log.ToString();

The ouput of log.ToString() is:

    request.InputStream.Position = "0"
    Original Input: ""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:05:40+00:00Added an answer on May 11, 2026 at 7:05 pm

    By the time it gets to your service the request is processed and not available to you.

    However … you could attach a message inspector. Message Inspectors allow you to fiddle with the message before it reaches your operation implementations. You could create a buffered copy of the message, and copy it into the OperationContext.Current.

    Ugly hack of course, and it will mean memory overhead as now two copies of the message are floating about for every request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a asp.net 2.0 web site with WCF service hosted inside it running
I have an IIS-Hosted WCF service and would like to make it available at
I have a WCF service hosted in IIS and it is consumed by an
I have a WCF (v3.5 with webHttpBinding) service hosted in IIS 6. I would
I have an IIS-hosted WCF service which is configured to use basicHttpBinding with transport
I am developing a solution in Visual Studio 2010 that has a WCF RESTful
(Please read comment as i have a fix) Hi, I have created a WCF
I want to authenticate users of a WCF service against custom Membership and Role
I am trying to write some unit tests that test the endpoints for my
I'm trying to model a request submission/ approval /completion scenario. I'm using a flowchart

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.