应该修改什么来更改 C# 中 Web 服务的 URL?

发布于 2024-09-01 19:32:09 字数 199 浏览 2 评论 0原文

我有一个问题,不久前我通过复制所有生成的代码(复制粘贴 .cs 内容的文本)将 Webservice 代理类添加到我的应用程序中。

它成功了!

但现在我需要更改此 Web 服务代理类使用的 URL,并且我不确定在代码中更改什么以及在哪里更改。

如果您能给我一条线索,指导我找到正确的位置,以便我可以更新网络服务的 URL,我将不胜感激。

I have one problem and it is some time ago I have added a Webservice proxy class into my application by copying all the generated code (copy paste the text of the .cs content).

And it worked!

But now I need to change the URL used by this web-service proxy class and I am not sure what and where to change in the code.

I would appreciate if you can give me a clue that can guide me to find the right place so that I can update the url of the web service.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纸伞微斜 2024-09-08 19:32:09

如果它是生成的 asmx webservice 代理,则代理类有一个属性 - URL
您可以在创建代理对象的位置设置 URL 属性,也可以将其硬编码到代理类中。
默认情况下,生成的代理类在构造函数中包含代码,用于从应用程序设置中设置 URL 属性。

If it´s a generated asmx webservice proxy the proxy class have a property - URL.
You can set the URL property where you create the proxy object or you can hard code it into the proxy class.
By default a generated proxy class have code in the constructor to set the URL property from application settings.

迷鸟归林 2024-09-08 19:32:09

您应该使用 web.config 更改 URL。
如果您转到添加的 Web 引用的属性,您应该会看到一个名为“'URL Behaviour'”的属性。将其值设置为“动态”并提供 URL。这将在 web.config 中创建一个条目,并且每当您更改该条目时,都会采用该 URL。
更多信息此处

You should change the URL using web.config.
If you go to the properties of the web reference added, you should see a property named "'URL Behavior'". Set the value of that to "dynamic" and supply the URL. That would make an entry in the web.config and whenever you change that entry, that URL will be taken.
More info here.

猫腻 2024-09-08 19:32:09

使用 URL 属性

Use the URL property

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文