Siverlight访问WCF The remote server returned an unexpected response: (404) Not Found 解决办法

    写完上一个试验项目,基本上技术上没有什么大的难点了,我马上开始写我计划了好几天的项目。

    不过,刚一开始,就遇到点小麻烦:Silverlight程序访问WCF服务时,调试错误信息如下:

用户代码未处理 System.ServiceModel.ProtocolException
  Message="The remote server returned an unexpected response: (404) Not Found."
  StackTrace:
       位于 System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       位于 System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
       位于 System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       位于 System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
       位于 TISCS.Bamhut.Paper.BamhutService.BamhutServiceClient.BamhutServiceClientChannel.EndUserLogin(IAsyncResult result)
       位于 TISCS.Bamhut.Paper.BamhutService.BamhutServiceClient.TISCS.Bamhut.Paper.BamhutService.IBamhutService.EndUserLogin(IAsyncResult result)
       位于 TISCS.Bamhut.Paper.BamhutService.BamhutServiceClient.OnEndUserLogin(IAsyncResult result)
       位于 System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
  InnerException:

    郁闷!到网上找了找资料,参考了一下这两个帖子:

一:http://forums.iis.net/t/1149643.aspx  二:http://www.cnblogs.com/invinboy/archive/2008/06/29/1232037.html

    大概的意思是添加一个clientaccesspolicy.xml文件(点击下载此文件),文件内容如下:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

    至于这个文件的存放位置,帖子二做了较详细的说明,但我个人认为还不够详细,其实,这个文件,是要放在IIS站点的根目录下的,不是WCF所在目录,也不是Web项目根目录,更不是Silverlight所在的目录,一定要在localhost所在的物理目录!

    问题已解决,解决方案给大家共享一下。以上内容如有错误或疏漏,敬请指正。

转载于:https://www.cnblogs.com/tiscs/archive/2008/07/14/1242901.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值