visual-studio Visual Studio Web 参考中的 URL 行为
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1531202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
URL Behaviour in a Visual Studio Web Reference
提问by David A Gibson
Please can some one explain exactly what the URL Behaviour (Static or Dynamic) property for a Web Reference in Visual Studio is for.
请有人准确解释 Visual Studio 中 Web 引用的 URL 行为(静态或动态)属性的用途。
I believe it affects where the URl for the Web Service is stored but I don't have a clear understanding.
我相信它会影响 Web 服务的 URl 的存储位置,但我没有明确的理解。
采纳答案by Janis Veinbergs
I believe it affects where the URl for the Web Service is stored but I don't have a clear understanding.
我相信它会影响 Web 服务的 URl 的存储位置,但我没有明确的理解。
That's right.
那就对了。
If you set it to dynamic, afterwards you can change url of web service (WebService.Url). Details here.
如果您将其设置为动态,则之后您可以更改 Web 服务的 url (WebService.Url)。详情请看这里。
回答by bytebuster
Here's a bit more complete answer.
这是一个更完整的答案。
Dynamicautomatically adds a setting that specifies Web Service URL. Yes, it can be managed through app.config, but the setting must reside in a specific place of app.configunder <applicationSettings>.
动态自动添加一个指定 Web 服务 URL 的设置。是的,它可以通过托管app.config,但设置必须驻留在一个特定的地方app.config下<applicationSettings>。
Staticmakes the proxy's constructor to initialize Urlproperty to its original value.
静态使代理的构造函数将Url属性初始化为其原始值。
So if you have your own URL handling (e.g. the URL is retrieved from the database or resides in another section of app.config), URL Behaviourmust be Staticand changed later in your custom code.
因此,如果您有自己的 URL 处理(例如,该 URL 是从数据库中检索的或驻留在 的另一部分中app.config),则URL Behaviour必须Static稍后在您的自定义代码中进行更改。

