开发者

Difference between Setting.settings and web.config?

开发者 https://www.devze.com 2022-12-31 22:10 出处:网络
This might sound a bit dumb. I always had this impression that web.config should store all settings which could be subject to change post-build and setting.settings should have the one which may cha

This might sound a bit dumb.

I always had this impression that web.config should store all settings which could be subject to change post-build and setting.settings should have the one which may change pre-build.

but I have seen projects which had like connection string in setting.settings. Connection Strings should always been in web.conf开发者_开发知识库ig, shouldn't it?

I am interested in a design perspective answer.

Just a bit of background: My current scenario is that I am developing a web application with all the three tiers abstracted in three separate visual studio projects thus every tier has its own .settings and .config file.


Web.config is mostly meant for configuration, and it also stores the default values of your settings.

Settings.settings is just a convenience file for Visual Studio to provide a UI for editing your settings.

The .config comes in two different flavors: App.config for Windows applications, which will be named YourApplication.exe.config, and the Web.config for web applications. They share the same schema, syntax, and options.

  • You may notice that if you add a setting to Settings.settings, it gets added to the .config as well.
  • The .config must be deployed with apps, but Settings.settings doesn't need to.


Setting.settings is a class, it is not used to store the connection string as such, it is used to expose a specific connection string from web/app.config as a property on a class. VS does also tend to hard code a default value if the particular connnection string cannot be found.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号