我在 MyDataService.svc.cs 中有以下代码(这是 DevExpress 的一个示例):
namespace MyDataService {
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[JSONPSupportBehavior]
public class DataService : DataService<TestDataEntities>, IServiceProvider {
public static void InitializeService(DataServiceConfiguration config) {
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
public object GetService(Type serviceType) {
if (serviceType == typeof(IDataServiceStreamProvider)) {
return new ImageStreamProvider();
}
return null;
}
protected override void OnStartProcessingRequest(ProcessRequestArgs args) {
CustomBasicAuth.Authenticate(HttpContext.Current);
if (HttpContext.Current.User == null)
throw new DataServiceException(401, "Invalid login or password");
base.OnStartProcessingRequest(args);
}
}
}
因此,虽然这将检查实体的用户名和密码,但config.SetEntitySetAccessRule
设置为AllRead
. 是否有人只能在诸如 www.website.com/MyDataService.svc/Customer (其中 Customer 是表格)之类的 url 上看到此信息。如果不是这样,有人可以填补我面临的概念空白。谢谢!