2
votes

I have a WCF service running in IIS 8.5 on Windows Server 2012 R2 with AppPool Integrated.

I open url in the server: http://localhost:50123/MyService.svc

I have HTTP 500 Internal Server Error. (IExplorer cannot show the page)

I have not found the problem in Event logs, IIS Logs.

I apply this steps: https://peter.hahndorf.eu/blog/iislogging.html

Disable IE “Friendly HTTP error messages”

<customErrors mode=”Off” />

<httpErrors errorMode="Detailed" />

<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>

I use WCF tracing, but not view the error messsage.

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel" propagateActivity="true" switchValue="All">
        <listeners>
          <add name="xmlTraceListener" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="All">
        <listeners>
          <add name="xmlTraceListener" />
        </listeners>
      </source>
      <source name="System.Net">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.HttpListener">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.Sockets">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.Cache">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xmlTraceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Servitelco\Logs\IntegrationLabor\ServiceWcf.svclog" />
      <add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Servitelco\Logs\IntegrationLabor\SystemNet.trace.log" traceOutputOptions="DateTime" />
    </sharedListeners>
    <switches>
      <add name="System.Net" value="Verbose" />
      <add name="System.Net.Sockets" value="Verbose" />
      <add name="System.Net.Cache" value="Verbose" />
      <add name="System.Net.HttpListener" value="Verbose" />
    </switches>
  </system.diagnostics>


 <system.serviceModel>

        <diagnostics>
            <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxSizeOfMessageToLog="26214445" />
        </diagnostics>

I setup "Failed Request Tracing", for All content, verbose error logging, HTTP errors in range 400-600.

I open fr000001.xml file from %systemdrive%\inetpub\logs\FailedReqLogFiles\W3SVC1

I only view MODULE_SET_RESPONSE_ERROR_STATUS Warning:

ModuleName ManagedPipelineHandler
Notification 128
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0 ErrorCode 0
ConfigExceptionInfo
Notification EXECUTE_REQUEST_HANDLER
ErrorCode The operation completed successfully. (0x0)

Error 500:

HttpStatus 500
HttpReason Internal Server Error

and successfully ?

ErrorCode The operation completed successfully. (0x0)

Not more info about the error.

About the error:

I have and WCF Inspector with IDispatchMessageInspector

Like https://patrickdesjardins.com/blog/wcf-inspector-for-logging

The error is about attribute logFileName="c:\log.txt"

If the path exists, all is OK. If the path NOT exists, I get Http 500 Error.

 <extensions>
            <behaviorExtensions>
                <add name="myLogBehavior"
                     type="MyServiceA.LogFileBehaviorExtensionElement, MyServiceA" />
            </behaviorExtensions>
        </extensions>


  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <MyLogFileBehavior logFileName="C:\Servitelco\Logsxxx\IntegrationLabor\log.txt" />
    </behavior>
  </serviceBehaviors>

<endpointBehaviors>
          <behavior name="behavior1">
              <myLogBehavior logFileName="c:\log.txt" />
          </behavior>
      </endpointBehaviors>

This means there is an unhanded exception with in the code.

Event viewer, IIS Logs, WCF tracing, Failed Request Tracing not shown the error message, why? How get the full error message ? OS not logging the error in anyway ?

1
How did you configure WCF tracing? docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/… It is not trivial to read its log file, but every requests are logged there. The pattern showed in IIS FRT indicates this is a status code 500.0 returned from WCF, so you must spend enough time there on the tracing log.Lex Li
I use WCF Tracing, diagnostics. View updated question.Kiquenet
Like I commented earlier "The operation completed successfully" is expected, as IIS simply receive the error code from "ManagedPipelineHandler", ASP.NET or WCF. Without seeing your code and IIS setup in a live session, it would be difficult to suggest further. Can you open a support case via support.microsoft.com and work with Microsoft support?Lex Li
Source code for WCF Inspector is here: patrickdesjardins.com/blog/wcf-inspector-for-loggingKiquenet
Not sure if it helps but I had problems getting the WCF tracing to show up, and it turns out I hadn't given write permission to the directory where it was supposed to save the trace. After I just gave Full Control to all users, it put the error in there for me.colmde

1 Answers

0
votes

I had the same problem - 500 error returned to client, no event log error, no custom errors logged from Global.asax, Failed Request Tracing showed MODULE_SET_RESPONSE_ERROR_STATUS Warning for ManagedPipelineHandler.

Solved by adding a Try/Catch at the very highest level of my controller...

    <HttpPost>
    Public Function Main() As IHttpActionResult
    Try
       ... all logic here...
       Return ResponseMessage(New HttpResponseMessage(HttpStatusCode.OK))
    Catch Ex As Exception
       Errorcl.HandleException(err) 'internal logging of error
       Return ResponseMessage(New HttpResponseMessage(HttpStatusCode.InternalServerError))
    End Try