When you access WebService in Silverlight 2 beta 2, "the remote server returned an unexpected response: (404) No

Source: Internet
Author: User

In Silverlight 2 beta 2, when accessing WebService or WCF, this error is often prompted:
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.
In the address bar, enter the asmx or. SVC file to run properly.
After checking the information, we found that the client cross-origin access policy file (clientaccesspolicy. XML) was generated.
The correct file should be:

Clientaccesspolicy. xml file
<? XML version = "1.0" encoding = "UTF-8" ?>
< Access-Policy >
< Cross-Domain-Access >
< Policy >
< Allow-from HTTP-request-headers = "*" >
< Domain Uri = "*" />
</ Allow-from >
< Grant- >
< Resource Path = "/" Include-subpaths = "True" />
</ Grant- >
</ Policy >
</ Cross-Domain-Access >
</ Access-Policy >  

However, many netizens are confused about where the file is located? Or if I find a place, why does the change still not take effect?
It turns out that the address of the clientaccesspolicy. xml file is incorrect, for example, WebService The directory is Webservice1, The reference address is Http: // localhost/webservice1/WebService. asmx, whereas Silverlight Not in Http: // localhost/webservice1 Find in this directory Clientaccesspolicy. XML, Instead Http: // localhost/ Find this file . So assume that your IIS The default directory is "C: \ Inetpub \ wwwroot" Words , Webservice1/WebService. asmx is deployed in C: \ Inetpub \ wwwroot \ webservice1" Lower , So Clientaccesspolicy. xml It should be placed in" C: \ Inetpub \ wwwroot" Instead C: \ Inetpub \ wwwroot \ webservice1. However, when vs2008 is running in the debugging status, its URL is usually http: // localhost/ : Port Number/WebService. asmx, so we do not know clientaccesspolicy. where should the XML file be placed? In this case, I have not found a better solution, usually WebService. release asmx to IIS (http: // localhost/webservice1/WebService. asmx), and then perform debugging, which can solve the problem.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.