gpt4 book ai didi

wcf-data-services - WCF数据服务-请求错误

转载 作者:行者123 更新时间:2023-12-04 13:11:55 26 4
gpt4 key购买 nike

我在LINQ to SQL数据上下文之上做一个简单的WCF数据服务。
我的svc.cs文件非常简单。但是,当我从VS2012运行它时,我得到了通用的“请求错误”,没有更多信息。如何解决/解决问题?

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;
}
}
}

最佳答案

如果在服务上设置[ServiceBehavior(IncludeExceptionDetailInFaults=true)]属性,并将config.UseVerboseErrors设置为true,则在客户端会得到更清晰的错误消息。在投入生产之前,请务必删除这些设置,因为它们可能会导致意外的信息泄露:

[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;
}
}

关于wcf-data-services - WCF数据服务-请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12148977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com