views:

205

answers:

4

How can I have any uncaught exception get returned as a SOAP fault in my C# web service? It appears that IIS is 'catching' the exception and displaying it on the default error. Below is santized web.config.

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <system.web>
    <httpRuntime enableVersionHeader="false" />
    <sessionState mode="Off" />
    <compilation defaultLanguage="c#" debug="true" />
    <authentication mode="None" />
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    <webServices>
      <protocols>
        <remove name="HttpPost"/>
        <remove name="HttpGet"/>
        <remove name="Documentation"/>
      </protocols>
        <remove name="HttpSoap12" />
      </protocols>
    </webServices>
  </system.web>
</configuration>
A: 

Hello, I believe this link describes what you're looking for:

http://aspalliance.com/727_CodeSnip_Handling_SOAP_Exceptions_in_Web_Services

Adam Alexander
A: 

Try removing the customErrors section from the config.

codemeit
A: 

It turns out there was a code issue in the Application_EndRequest method of an HttpModule that was causing the problem.

J. Scarbrough
A: 

it turns ou some bad logic in an HttpModule was causing the application to error out. once this was resolved the application behaved as expected.

J. Scarbrough