开发者

Silverlight Localhost on Xampp

I am trying to retrive data to my SL application from PHP, MySQL service which is hosted locally on Xampp. I can see my php file running OK and deliver results via JSON (http://localhost/silverlight/data.php) but SL cannot receive it. I belive it has something to do with correct URl path but I cant figure it out. Also I've putted clientaccesspolicy.xml file to allow cross-domain access but with no avail:(

 public partial class MainPage : UserControl
{
    WebClient wc = new WebClient();
    ObservableCollection<ToDoItem> myToDoList = new ObservableCollection<ToDoItem>();
    string baseURI = "http://localhost/silverlight/";

    public MainPage()
    {
        InitializeComponent();
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
        wc.DownloadStringAsync(new Uri(baseURI + "data.php",UriKind.Absolute));
    }



    void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventA开发者_如何学Pythonrgs e)
    { 

        if (e.Error == null && e.Result!= "")
        { JsonValue completeResult = JsonPrimitive.Parse(e.Result);
            string resultType = completeResult["returnType"].ToString().Replace("'", "").Trim();}


The clientaccesspolicy.xml file you use only allows cross-domain access for web service requests (as specified by http-request-headers="SOAPAction")

For WebClient to work the way you use it, you need to enable content requests as well.

Try specifying http-request-headers="*" or http-request-headers="SOAPAction,Content-Type".

Also, do check that the clientaccesspolicy.xml file is located at the root of the host, i.e. http://localhost/clientaccesspolicy.xml. Eventually when you decide to deploy your application, you'll have to make sure the file is placed in the root of the deployment host as well, e.g. http://example.org/clientaccesspolicy.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜