当我添加“Web 引用”时,我们将 asmx 页面的地址提供给 visual studio。
如何在运行时设置它?
最佳答案
我会赞成其他答案之一 - 它们几乎是正确的。
using (YourService service = new YourService())
{
service.Url = "http://some.other.url/";
// Now you're ready to call your service method
service.SomeUsefulMethod();
}
如果未使用 using block 并抛出异常,则可能会泄漏网络连接等资源。
关于c# - 在运行时设置服务 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2997885/