WCF service will not return 500 Internal Server Error. Instead, only 400 Bad Request

clebAbeclussy

New Member
I've created a simple RESTful WCF file streaming service. When an error occurs, I would like a 500 Interal Server Error response code to be generated. Instead, only 400 Bad Requests are generated.When the request is valid, I get the proper response (200 OK), but even if I throw an Exception I get a 400.IFileService:\[code\][ServiceContract]public interface IFileService{ [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/DownloadConfig")] Stream Download();}\[/code\]FileService:\[code\][AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]public class GCConfigFileService : IGCConfigFileService{ public Stream Download() { throw new Exception(); }}\[/code\]Web.Config\[code\]<location path="FileService.svc"><system.web> <authorization> <allow users="*"/> </authorization></system.web></location><system.serviceModel><client /><behaviors> <serviceBehaviors> <behavior name="FileServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="web"> <webHttp/> </behavior> </endpointBehaviors></behaviors><serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /><services> <service name="FileService" behaviorConfiguration="FileServiceBehavior"> <endpoint address="" binding="webHttpBinding" bindingConfiguration="FileServiceBinding" behaviorConfiguration="web" contract="IFileService"></endpoint> </service></services><bindings> <webHttpBinding> <binding name="FileServiceBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </webHttpBinding></bindings>\[/code\]
 
Back
Top