在运行时设置服务 URL
当我添加“Web 参考”时,我们将 asmx 页面的地址提供给 Visual Studio。
我如何在运行时设置它?
When I am adding the "Web Reference" we are giving the address to the asmx page to visual studio.
How Can I set this at run time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会投票赞成其他答案之一 - 它们几乎是正确的。
如果未使用 using 块并引发异常,则可能会泄漏网络连接等资源。
I would have upvoted one of the other answers - they're almost correct.
If a using block is not used, and an exception is thrown, then resources like network connections can be leaked.
只需在调用任何服务方法之前设置对象的 Url 属性即可:
Just set the Url property of the object before you call any of the service methods: