服务参考:使用网站的配置文件 [英] service reference: Use config file of web site

查看:80
本文介绍了服务参考:使用网站的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有这个很酷的Web服务,可以将它添加为对网站的服务引用.一切正常:所有呼叫均可完成,效果很好.

现在...我在网站的web.config的appsettings中添加了一些值.我希望服务 读取这些值并对其执行操作.
但是该服务具有其自己的配置文件,因此未使用网站的配置文件.

有没有一种方法可以让服务读取网站的配置文件,而不是它自己的配置文件?
如果是这样:如何?如果不是:还有其他想法吗?我希望每个网站(多个网站提供相同的服务)都具有不同值(虽然有相同的键)的自己的配置文件.

在此先谢谢您.

Hi,

I have this cool web service that I add as a service reference to a web site. All works fine: All calls can be done and results are good.

Now... I have added some values to the appsettings of the web.config in the web site. I want the service to read these values and act on it.
But the service has it''s own config file, so the config file of the web site is not used.

Is there a way to let the service read the config file of the web site and not it own config file?
If so: How? If not: Any other ideas? I want each web site (multiple web sites to same service) to have it''s own config file with different values (same keys though).

Thanks in advance.

推荐答案

如果该服务独立于网站,则您将不允许它从另一个网站读取配置文件(除非它在同一盒子上,并且允许它读取文件系统.

如果要控制服务的代码,则可能要在服务调用中允许使用参数选项,以将值从配置文件推送到服务调用?
-或-
如果它们都在同一个盒子或同一个本地网络上运行,您也许可以使用数据库来存储设置?
If the service is independent of the website you are not going to be able to allow it to read a config file from another website (unless it is on the same box and you allow it to read the file system).

If you are controlling the code for the service you might want to allow for a parameters option in your service call to push the values from your config file to the service call?
-or-
If they are all running on the same box or in the same local network you might be able to use a database to store the settings?


据我了解,该服务是该网站的一部分,因此您可以阅读它的配置.如果您创建了ConfigurationSection(请参阅: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx [ ^ ]),只需打开根配置(或您需要的配置),即可在网站的任何部分使用它.

由您决定要添加一个属性,该属性通过其DNS名称将该节的config分支映射到站点,但是,如果您想在许多站点下使用相同的服务,则会造成某种程度的混乱.是否将相同的虚拟路径添加到所有站点?或者如何将服务文件准确链接到许多站点?
As I understand the service is part of the site, thus you can read it''s configuration. If you created a ConfigurationSection (see: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx[^]), you can simply use it from any part of the site, by opening the root config (or the one you need).

It is up to you to add an attribute that maps a config branch of the section to a site by its DNS name, but it is somehow confusing, if you want to use the same service under many sites. Is the same virtual path added to all sites - or how do you link exactly the service files to many sites?


这篇关于服务参考:使用网站的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆