I have an ASP.NET application. It resides within another ASP.NET application. I put my DLL in the other apps bin folder and have a subdirectory with my aspx files. I can't edit the main app's Web.config.
我有一个ASP.NET应用程序。它驻留在另一个ASP.NET应用程序中。我将我的DLL放在其他apps bin文件夹中,并有一个包含我的aspx文件的子目录。我无法编辑主应用程序的Web.config。
So where can I store configuration settings? For example, this is an app that will get deployed to various clients. I want to store the client name used for display in the headers and such. And the location of a logo file.
那么我在哪里可以存储配置设置?例如,这是一个将部署到各种客户端的应用程序。我想在标题中存储用于显示的客户端名称等。以及徽标文件的位置。
3 个解决方案
#1
You can put a web.config file on the folder your ASPX files reside and .NET will take care of nesting them and aggregate its contents.
您可以将web.config文件放在ASPX文件所在的文件夹上,.NET将负责嵌套它们并聚合其内容。
#2
You can also just create a Settings.config XML file and put it wherever you want (the .config extension will prevent it from being viewable through an HTTP request), then wrap it with a Settings class and talk to that Settings class from your application.
您也可以创建一个Settings.config XML文件并将其放在任何地方(.config扩展名将阻止它通过HTTP请求查看),然后使用Settings类包装它并从您的应用程序与该Settings类对话。
#3
You can use Settings.Settings
to store it. This example might help. You can have multiple settings files and access any of them, just as you would for any other class.
您可以使用Settings.Settings来存储它。这个例子可能有帮助。您可以拥有多个设置文件并访问其中任何一个,就像您对任何其他类一样。
#1
You can put a web.config file on the folder your ASPX files reside and .NET will take care of nesting them and aggregate its contents.
您可以将web.config文件放在ASPX文件所在的文件夹上,.NET将负责嵌套它们并聚合其内容。
#2
You can also just create a Settings.config XML file and put it wherever you want (the .config extension will prevent it from being viewable through an HTTP request), then wrap it with a Settings class and talk to that Settings class from your application.
您也可以创建一个Settings.config XML文件并将其放在任何地方(.config扩展名将阻止它通过HTTP请求查看),然后使用Settings类包装它并从您的应用程序与该Settings类对话。
#3
You can use Settings.Settings
to store it. This example might help. You can have multiple settings files and access any of them, just as you would for any other class.
您可以使用Settings.Settings来存储它。这个例子可能有帮助。您可以拥有多个设置文件并访问其中任何一个,就像您对任何其他类一样。