Application Settings in Web projects
-
Hi, I want to make my website configurable so I want to include some settings somewhere (maybe in web.Config file), when I was reading about this topic I found that Windows Form Apps can have "Application Settings" file in which you can visually create and remove user scope and application scope settings, which seems to be an easier way to make a project configurable, but I noticed that I can't store whatever objects I want, for example I can't store List object, and I don't know if this type of settings is applicable to web applications. In short, I want to know the best way to make a Web Project Configurable in terms of: 1. It is easy (and not time consuming) to add/remove settings. 2. It can store custom objects for example: MyCustomClass. Any Ideas? Thanks alot
And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat
-
Hi, I want to make my website configurable so I want to include some settings somewhere (maybe in web.Config file), when I was reading about this topic I found that Windows Form Apps can have "Application Settings" file in which you can visually create and remove user scope and application scope settings, which seems to be an easier way to make a project configurable, but I noticed that I can't store whatever objects I want, for example I can't store List object, and I don't know if this type of settings is applicable to web applications. In short, I want to know the best way to make a Web Project Configurable in terms of: 1. It is easy (and not time consuming) to add/remove settings. 2. It can store custom objects for example: MyCustomClass. Any Ideas? Thanks alot
And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat
Mohammad A Gdeisat wrote:
It is easy (and not time consuming) to add/remove settings.
Put it in custom configuration files. Write classes for reading and writing to these files. For primitive values, you should be able to open this config file manually and edit the required settings.
Mohammad A Gdeisat wrote:
It can store custom objects for example: MyCustomClass.
This also can be kept on XML files. You need to serialize the custom type's object and encode to
Base64
. Problem with this approach is you need to create some user interface to manage this and can't be edited by opening the file directly.Mohammad A Gdeisat wrote:
I can't store List object, and I don't know if this type of settings is applicable to web applications.
As I said, it can be serialized and stored. But I will not suggest keeping custom types in configuration files as serialized. Because you can't manage it easily. Recommended approach is to keep values which can be used to create the custom type. Read this values and create your type and if it is used frequently and not user specific, cache it. To explain my point, assume you have to keep details of people who are administrators of the site. You can keep your configuration entries like
<administrators>
<administrator>
<name>name1</name>
<role>somerole</role>
</administrator>
<administrator>
<name>name2</name>
<role>somerole</role>
</administrator>
</administrators>You need to create a type for administrator with necessary properties. Read these details from this configuration and fill your custom types. Cache it in static variables or ASP.NET cache object for future use. XML serialization also works well. Hope this helps :)
Navaneeth How to use google | Ask smart questions
-
Hi, I want to make my website configurable so I want to include some settings somewhere (maybe in web.Config file), when I was reading about this topic I found that Windows Form Apps can have "Application Settings" file in which you can visually create and remove user scope and application scope settings, which seems to be an easier way to make a project configurable, but I noticed that I can't store whatever objects I want, for example I can't store List object, and I don't know if this type of settings is applicable to web applications. In short, I want to know the best way to make a Web Project Configurable in terms of: 1. It is easy (and not time consuming) to add/remove settings. 2. It can store custom objects for example: MyCustomClass. Any Ideas? Thanks alot
And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat
-
Mohammad A Gdeisat wrote:
It is easy (and not time consuming) to add/remove settings.
Put it in custom configuration files. Write classes for reading and writing to these files. For primitive values, you should be able to open this config file manually and edit the required settings.
Mohammad A Gdeisat wrote:
It can store custom objects for example: MyCustomClass.
This also can be kept on XML files. You need to serialize the custom type's object and encode to
Base64
. Problem with this approach is you need to create some user interface to manage this and can't be edited by opening the file directly.Mohammad A Gdeisat wrote:
I can't store List object, and I don't know if this type of settings is applicable to web applications.
As I said, it can be serialized and stored. But I will not suggest keeping custom types in configuration files as serialized. Because you can't manage it easily. Recommended approach is to keep values which can be used to create the custom type. Read this values and create your type and if it is used frequently and not user specific, cache it. To explain my point, assume you have to keep details of people who are administrators of the site. You can keep your configuration entries like
<administrators>
<administrator>
<name>name1</name>
<role>somerole</role>
</administrator>
<administrator>
<name>name2</name>
<role>somerole</role>
</administrator>
</administrators>You need to create a type for administrator with necessary properties. Read these details from this configuration and fill your custom types. Cache it in static variables or ASP.NET cache object for future use. XML serialization also works well. Hope this helps :)
Navaneeth How to use google | Ask smart questions
Yes, this definitely gives a better view :) Thanks for your time :)
And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat