在Silverlight 2 中访问webservice 时,出现“The remote server returned an unexpected response: (404) Not Found”的解决办法
2008-08-13 17:17
696 查看
在silverlight 2 中访问webservice,看不见任何错误提示,在便宜下才发现 程序执行到系统自动生成的EndGetMethods(System.IAsyncResult result) 时候,提示"The remote server returned an unexpected response: (404) Not Found" ,怎么找都找不到这个为什么错误.后来在网络上才看到这个是sl 在不同的域上访问会出这样的错误, 然后把webservice 跟silverlighttestpage 的项目放在一起,就可以了。
那在不同的域的时候,应该怎么处理呢。查了一下网络的很多提示说添加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>
但是测试还是不行, 原因在于sl 访问的时候,是找到这个webservice.asmx站点的上一级 目录下的clientaccesspolicy.xml 文件,比如 webservice.asmx 是在“c:\inetpub\wwwroot\webservice”的目录下,而sl 查找clientaccesspolicy.xml 是在"c:\inetpub\wwwroot\" 这个目录查找的.所以你应该把clientaccesspolicy.xml 放在"c:\inetpub\wwwroot\" ,在vs调试中,因为直接引用解决方案的项目时,都是http;//localhost:端口号 ,这样就不知道要将clientaccesspolicy.xml 文件放置哪里,所以需要将webservice发布到本地iis下面,然后在执行!
主要放置的路径在webservice.asmx 站点的上一级站点目录下.如你是http://localhost/webservice 的目录,那你xml的文件放置的地址应该在 http://localhost/ 这个站点下.
那在不同的域的时候,应该怎么处理呢。查了一下网络的很多提示说添加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>
但是测试还是不行, 原因在于sl 访问的时候,是找到这个webservice.asmx站点的上一级 目录下的clientaccesspolicy.xml 文件,比如 webservice.asmx 是在“c:\inetpub\wwwroot\webservice”的目录下,而sl 查找clientaccesspolicy.xml 是在"c:\inetpub\wwwroot\" 这个目录查找的.所以你应该把clientaccesspolicy.xml 放在"c:\inetpub\wwwroot\" ,在vs调试中,因为直接引用解决方案的项目时,都是http;//localhost:端口号 ,这样就不知道要将clientaccesspolicy.xml 文件放置哪里,所以需要将webservice发布到本地iis下面,然后在执行!
主要放置的路径在webservice.asmx 站点的上一级站点目录下.如你是http://localhost/webservice 的目录,那你xml的文件放置的地址应该在 http://localhost/ 这个站点下.
相关文章推荐
- 在Silverlight 2 beta 2 中访问webservice 时,出现“The remote server returned an unexpected response: (404) Not Found”的解决办法
- Siverlight访问WCF The remote server returned an unexpected response: (404) Not Found 解决办法
- WCF / Silverlight 2 Beta 2: "The remote server returned an unexpected response: (404) Not Found."
- Silverlight调用WebService出现CommunicationException The remote server returned an error: NotFound的一种可能原因
- 关于Silverlight中WebService调用出现CommunicationException The remote server returned an error: NotFound
- Silverlight调用WCF服务出现The remote server returned an error: NotFound可能原因
- WP8 调用webservice 错误 The remote server returned an error: NotFound 解决
- The remote server returned an error: (404) Not Found
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
- 调用WCF出现 The remote server returned an error: (401) Unauthorized. 错误
- 运行iis出现:The server has encountered an error while loading an application ……的解决办法【转】
- Chrome访问MSDN主页失败,显示The specified CGI application encountered an error and the server terminated the process.的解决办法
- Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 解决办法
- 运行iis出现:The server has encountered an error while loading an application ……的解决办法
- WCF 中,出现The remote server returned an unexpected response: (400) Bad Request.
- webService调用出现the remote server returned and error:NotFound
- WebService:The remote server returned an error: (400) Bad Request
- The remote server returned an error: (404) Not Found.
- Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 解决办法
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法