Silverlight WebRequest fails with “The URI prefix is not recognized”

让人想犯罪 __ 提交于 2019-12-25 02:44:47

问题


I have a silverlight library that is supposed to get make a web service request and receive an xml response:

   Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14");            
   WebRequest request = WebRequest.Create(uri);

However, WebRequest.Create(uri) fails with the exception "The URI prefix is not recognized".

Note that I am running the program using a unit test from a non-silverlight dll. I need to build a test suite for the app!

Any ideeas?


回答1:


Try setting the .Web project as the default startup project instead of the Silverlight project




回答2:


Have you tried adding the second parameter to the Uri constructor?

 Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14", UriKind.Absolute);  


来源:https://stackoverflow.com/questions/2246735/silverlight-webrequest-fails-with-the-uri-prefix-is-not-recognized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!