I am developing an ASP.NET MVC 5 application and I need to manage some global parameters, which are basically just a set of key-value-pairs. My requirements are the following:
Session
or serialized in QueryString
). My "brute force" approach for this would be just to implement a static class with List<Tuple<string,string>>
to keep the settings, use System.Web.Configuration.WebConfigurationManager
to populate initial values, use static properties to store and retrieve the list in a session variable and design a separate controller and view for managing the settings.
But this looks like re-inventing the wheel to me. Is there any (not necessarily full-fledged) pre-existing solution (in ASP.NET, or as a NuGet package) I might rest my efforts upon? Or maybe I am missing something fundamental in ASP.NET?
UPDATE : Depending on the nature of the parameter, some of them might have the lifetime of the Application
, whereas some of them are bound to the current user session. Therefore they need to be either preserved in a Session
object or "passed through" in every request.
这听起来像是最常见的方法,我认为使用会话变量没有任何问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.