Jor*_*mer 7 c# wcf iis-7 wcf-data-services
我正在玩WCF数据服务(ADO.NET数据服务).我有一个指向AdventureWorks数据库的实体框架模型.
当我从Visual Studio中调试我的svc文件时,它工作得很好. 我可以说/awservice.svc/Customers并取回我期望的ATOM提要.
如果我将服务(在ASP.NET Web应用程序中托管)发布到IIS7,则相同的查询字符串将返回500错误.根svc页面本身按预期工作并成功返回ATOM./ Customers路径失败.
这是我的授权在svc文件中的样子:
public class AWService : DataService<AWEntities>
{
public static void InitializeService( DataServiceConfiguration config )
{
config.SetEntitySetAccessRule( "*", EntitySetRights.All );
config.SetServiceOperationAccessRule( "*", ServiceOperationRights.All );
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
Run Code Online (Sandbox Code Playgroud)
更新:我启用了详细错误并在XML消息中获取以下内容:
<innererror>
<message>The underlying provider failed on Open.</message>
<type>System.Data.EntityException</type>
<stacktrace>
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(
...
...
<internalexception>
<message>
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
</message>
<type>System.Data.SqlClient.SqlException</type>
<stacktrace>
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, ...
Run Code Online (Sandbox Code Playgroud)
在我看来,这是一个SQL身份验证错误,IIS正在一个无法访问您的SQL服务器的用户下运行其appPool,当您在Visual Studio(本地)中毁了它将是一个不同的用户.检查用户服务器上的IIS正在使用的用户,并确保它有权在SQL中执行您想要的操作.
| 归档时间: |
|
| 查看次数: |
3552 次 |
| 最近记录: |