从WCF数据服务中的任何实体中删除对象会给我一个异常

本文关键字:一个 异常 对象 服务 数据 WCF 任何 删除 实体 | 更新日期: 2023-09-27 18:10:10

我有一个具有多个实体的wcf数据服务。当我得到这个异常时,我有一个从任何实体删除对象的问题。我的服务作为云服务托管在Azure中。

它给我这个错误消息"401 -未经授权:访问被拒绝由于无效的凭据。"

顺便说一下,它在本地主机上运行WCF数据服务时工作得很好。

System.Data.Services.Client.DataServiceRequestException was unhandled
  HResult=-2146233079
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.SaveResult.HandleResponse()
       at System.Data.Services.Client.BaseSaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at testODataClient.Program.Main(String[] args) in e:'Learn'My Projects'Visual Studio Projects'testODataClient'testODataClient'Program.cs:line 238
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       HResult=-2146233079
       Message=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
  <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
 </fieldset></div>
</div>
</body>
</html>
       StatusCode=401
       InnerException: 

从WCF数据服务中的任何实体中删除对象会给我一个异常

我找到了一个解决这个问题的方法,那就是将UsePostingTunneling设置为true

http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.useposttunneling.aspx

http://social.msdn.microsoft.com/forums/en us/ce63fde6 - 5547 - 447 - d - 8 d4d - e3699701d3e8/how -配置iis - 75 -允许插入和删除- - wcf数据服务——把————delete?forum=adodotnetdataservices

添加下列元素到web。配置可能是另一个解决方案

<authentication mode="None" />

见http://social.msdn.microsoft.com/forums/windowsazure/en - us/514f2e2d - 54 - a8 - 4516 - 976 d - 94 - a879209173/http -删除-请求- svc -返回- 4013 unauthorized?forum=windowsazuretroubleshooting