我试图在 ClientBin 中访问我的 .xml 文件,但没有成功。
代码:
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(xmlClient_DownloadStringCompleted);
Uri uri = new Uri("Antwerpen1.xml", UriKind.RelativeOrAbsolute);
xmlClient.DownloadStringAsync(uri);
调试 uri 时会引发以下错误:System.InvalidOperationException
结果抛出以下错误:相对 URI 不支持此操作
我可以使用以下路径访问我的文件:http://localhost:2546/contentManagement.Web/ClientBin/Antwerpen1.xml
我究竟做错了什么?
更新:我在主页后面的代码中尝试了相同的代码并且它有效。网络服务仍然没有结果。
update2:我发现这不是URI 的问题,而是 xmlClient.DownloadStringAsync 的问题。BaseAdress(我的clientbin中的xml文件存储的路径)由于某种原因是空的..
, 提前