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

  • SEARCH
  • Home
  • 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 8844051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:23:23+00:00 2026-06-14T11:23:23+00:00

I have a selfhosted webservice ( WebServiceHost ) that also delivers html sites (with

  • 0

I have a selfhosted webservice (WebServiceHost) that also delivers html sites (with JavaScript files,images etc.) The service runs fine in .net 4.0 (with vs2010).

Now I’ve installed vs2012 and my app seems to be broken (still using vs2010 – perhaps the installation of .net 4.5 is the cause). It compiles fine and I also have no runtime errors, but html and JavaScript seem to be broken under some circumstances. Here are the (I think) relevant codefragments:

Used Interface (System.Data.Services):

public interface IRequestHandler
{
    Message ProcessRequestForMessage(Stream messageBody);
}

Creation of the message:

string filePath = _physicalPath + string.Join("\\", incomingRequest.UriTemplateMatch.RelativePathSegments.ToArray());
HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();

if (File.Exists(filePath) && SetContentType(responseProperty.Headers, Path.GetExtension(filePath).ToLower()))
{
    Message message = Message.CreateMessage(MessageVersion.None, "", HttpServiceBodyWriter.Create(filePath));
    message.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
    message.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);
}

HttpServiceBodyWriter:

class HttpServiceBodyWriter : StreamBodyWriter
{
    private System.IO.Stream _source = null;

    private HttpServiceBodyWriter(System.IO.Stream source) : base(false)
    {
        _source = source;
    }

    protected override void OnWriteBodyContents(System.IO.Stream stream)
    {
        _source.CopyTo(stream);
    }

    internal static HttpServiceBodyWriter Create(System.Net.WebResponse response)
    {
        return new HttpServiceBodyWriter(response.GetResponseStream());
    }

    internal static HttpServiceBodyWriter Create(string filePath)
    {
        return new HttpServiceBodyWriter(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
    }
}

If I request a HTML page, this delivers sometimes a corrupt page (see the double dtd definition and the empty tag after “head”):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <>
    .....

Somtimes the correct page is delivered:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8" />
....

It seems like the initial page request always delivers a correct page. Subsequential request go corrupt.

Has anyone an explanation for this strange behaviour? Any help appreciated (This problem reminds me of the c++ days).

This is the serviceModel section of the App.Config:

<system.serviceModel>
  <diagnostics>
    <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="300000" maxSizeOfMessageToLog="200000" />
  </diagnostics>
  <services>
    <service name="WcfTest.HttpService" behaviorConfiguration="DataServiceBehavior">
      <endpoint name="DataService" binding="webHttpBinding" bindingConfiguration="DataService" contract="System.Data.Services.IRequestHandler" />
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8080/TestSite/" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <endpointBehaviors />
    <serviceBehaviors>
      <behavior name="DataServiceBehavior">
        <serviceDebug includeExceptionDetailInFaults="False" />
        <dataContractSerializer maxItemsInObjectGraph="1000000" />
        <serviceMetadata httpGetEnabled="true" />
        <serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="2147483647" maxConcurrentSessions="200" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
    <webHttpBinding>
      <binding name="DataService" maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000" maxBufferSize="5000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
        <readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" maxBytesPerRead="5000000" />
        <security mode="None"/>
      </binding>
    </webHttpBinding>
  </bindings>
</system.serviceModel>

Update

I’ve created a small project, where you can reproduce this problem. You can download it here: https://skydrive.live.com/redir?resid=CBC3C885DE2032B8!131&authkey=!ALZOaSL0V0s-itM

simply press the refresh button of the browser several times until the corrupted html appears.

  • 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-06-14T11:23:24+00:00Added an answer on June 14, 2026 at 11:23 am

    This is a known issue with webHttpBinding + 4.5 on enabling message logging. And is the same as http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/2bc5e5a6-1971-46cb-8b4f-f1c46130faca.
    This issue happens when message logging is enabled in the service. Until a fix is available for this issue please disable message logging in your app config file by commenting out these lines from your config. I verified that your application works fine on disabling message logging. Hope this helps!

    <!--
    <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true"
    maxMessagesToLog="300000" maxSizeOfMessageToLog="200000" />-->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a self hosted wcf service with a startup task that runs netsh
I have a selfhosted WCF service application which I want to deploy by a
I have a self-hosted WCF that runs under network_service beautifully on \Server1, but needs
I have a WCF chat service that accepts duplex tcp connections. A single duplex
We have a WCF service that we recently switched from self-hosting to IIS-hosted. It
I have a web application (hosted in IIS) that talks to a Windows service.
I have self hosted net tcp WCF service that exposes two methods and the
I have a self hosted WCF Rest service that I am using to simulate
I have a self-hosted WCF service that is hosted by a desktop application. I
I have a WebService that is being called from an Iphone app (that I

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.