• 在Silverlight 2 beta 2 中访问webservice 时,出现“The remote server returned an unexpected response: (404) Not Found”的解决办法


        在Silverlight 2 beta 2中,访问webservice 或者 wcf 的时候,常常会出现这样的错误:
    An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code
    Additional information: The remote server returned an unexpected response: (404) Not Found.
       在地址栏中,直接输入asmx 或者.svc 文件,运行一切正常。
       查了下资料,发现是客户端跨域访问策略文件(clientaccesspolicy.xml)产生的问题。
       正确的文件应该是:

    clientaccesspolicy.xml 文件


         但是,很多网友却很迷惑,这个文件在什么地方?或者找到了地方,修改了为什么还是不生效呢?
         原来是clientaccesspolicy.xml 文件的地址不正确,比如我们webservice目录叫做webservice1,引用地址是http://localhost/webservice1/webservice.asmx,而silverlight不是在http://localhost/webservice1这个目录下找clientaccesspolicy.xml,而是在http://localhost/下找这个文件.所以假如你的IIS默认目录是"c:\inetpub\wwwroot"的话,webservice1/webservice.asmx是部署在“c:\inetpub\wwwroot\webservice1”,那么clientaccesspolicy.xml  就应该放在“c:\inetpub\wwwroot”而不是c:\inetpub\wwwroot\webservice1 下面。但是VS2008 在调试状态下运行的时候,其URL通常是http://localhost/:端口号/webservice.asmx ,这样我们就不知道clientaccesspolicy.xml 文件该放在什么地方了,这种情况我也没有找到比较好的解决办法,通常是把webservice.asmx 发布到IIS中(http://localhost/webservice1/webservice.asmx),然后再进行调试,这样一般都能解决问题。

     

  • 相关阅读:
    python-paramiko
    python函数
    pyinstaller打包py程序为exe文件
    centos7安装python3.6.4
    docker资源限制
    docker网络管理
    docker run命令
    dockerfile解析
    爬虫基础巩固
    爬取图虫网 示例网址 https://wangxu.tuchong.com/23892889/
  • 原文地址:https://www.cnblogs.com/invinboy/p/1232037.html
Copyright © 2020-2023  润新知