Creating a WCF Data Service is really easy thanks to the built-in item template. Unfortunately when something goes wrong, a useless
“The server encountered an error processing the request” message is returned.
There are 2 important settings that help you to return useful error messages.
“The server encountered an error processing the request” message is returned.
There are 2 important settings that help you to return useful error messages.
This is especially useful when something failes during the WCF request pipeline and the WCF Data Service couldn’t be initialized.1. Add a WCF serviceDebug behavior with the IncludeExceptionDetailInFaults property set to true.
1: <system.serviceModel>
2: <behaviors>
3: <serviceBehaviors>
4: <behavior>
5: <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
6: <serviceDebug includeExceptionDetailInFaults="true"/>
7: </behavior>
8: </serviceBehaviors>
9: </behaviors>
10: </system.serviceModel>
2. Set UseVerboseErrors to true in the ServiceConfiguration
1: public class WcfDataService2 : DataService<DataContext>
2: {
3: // This method is called only once to initialize service-wide policies.
4: public static void InitializeService(IDataServiceConfiguration config)
5: {
6: config.UseVerboseErrors = true;
7: config.SetEntitySetAccessRule("*", EntitySetRights.All);
8: }
9: }