I try to add RESTful service to my website, I followed samples from site: http://wcf.codeplex.com/ (Web API Preview 5) and integrated the sample to my web application. the sample worked well at local, but after I upgrate to Winhost server and changed client.Get("http://localhost:9000/api/contacts"); to client.Get("http://www.myDomain.net/api/contacts"); the Web API did not work. Can anyone give me a help, Thanks.
Sorry for the delay. the Web API URL is: http://www.hezi.net/api/contacts I create a simple test page, it worked on local: http://www.hezi.net/WCF/Test/WCF_Test.aspx Thanks.
Hi Allegro, I am back from work. I have turn <customErrors mode="Off"> Now the error displayed. The error is caused by following code which access Web API, it works on local protected void ButtonGetContact_Click(object sender, EventArgs e) { HttpClient client = new HttpClient(); HttpResponseMessage resp = client.Get("http://www.HeZi.net/api/contacts"); if (resp.IsSuccessStatusCode) { List<Contact> contacts = resp.Content.ReadAs<List<Contact>>(); LabelContactID.Text = contacts[0].ContactId.ToString(); LabelContactName.Text = contacts[0].Name; } }
Try to change the permission level to FULL modifying your web.config file as follow <configuration> <system.web> <trust level="Full" /> </system.web> </configuration>