Is there an easy way to store user settings in an asp.net mvc app? For example, settings such as how often they want notifications, where to send notifications and anything else you can think of that the user would personalize for themselves.
Is there some built in thing in .net that can do this? I'd like to store the settings in the database with a foriegn key that links to that user.
If there is no built in .net features for this, how would I design my database table for settings? (just an example)
Do you want them to be persistent? If there aren't many of them, store them in a cookie.
If you can't store them in a cookie, then store them in a database table:
UserPreferences
---------------
Id
UserId
PreferenceName
Value
If you're worried about normalization and all that, then you could always add another table:
Preferences
-------------
Id
Name
Type
And your UserPreferences table would become:
UserPreferences
---------------
Id
UserId
PreferenceId
Value
I could go forever on possible tables, or persistence mechanisms. The question is, what sort of preferences are these? Session? Lifetime?
The Built in .Net Membership & Roles engine allows you to store user profile information.
Here's an intro on getting it running in MVC.
Here's a sample of someone using the API to talk to the store.
Here's some basics on the .Net Membership & Roles engine...
You'll want to focus on the Personalization part of the engine (webforms sample but you should be able to adapt).
If for some reason you need more or to do it a bit differently you can create your own provider...
Well you could have a table in the database that will contain the user preferences:
Preferences
-----------
Id <- PK
UserId <- FK pointing to the User table
Setting1
Setting2
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With