I am doing a simple WCF Data service on top of LINQ to SQL data context. My svc.cs file is very simple. However, when I run it from VS2012, I get a generic "Request Error" with no more information. How can I troubleshoot/resolve it?
using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using MyApp.Business.Pmw.DataAccess;
namespace MyApp.DataService
{
public class SystemData : DataService<PmwModelDataContext>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("SysParam", EntitySetRights.ReadMultiple);
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
// config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
}
If you set the [ServiceBehavior(IncludeExceptionDetailInFaults=true)]
attribute on the service and set config.UseVerboseErrors
to true
, you will get a much clearer error message on the client side. Please be sure to remove these settings before you go to production as they could result in unintentional information disclosure:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class FileService : DataService<FileContext>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With