asp.net - Best Practices when using .NET Session for temporary storage? -
i'm still relatively new .net , asp.net mvc, , have had few occasions nice store information retrieved db temporarily can used on subsequent server request client. have begun using .net session store information, keyed off of timestamp, , retrieve information using timestamp when hit server again.
so basic use case:
- user clicks 'query' button gather information system.
- in js, generate timestamp of current time, , pass server request
- on server, gather information db
- on server, use unique timestamp client key session store response object.
- return response object client
- user clicks 'generate report' button (will format query results excel doc)
- pass same timestamp #2 down server again, , use gather query results #4.
- generate report w/o additional db hit.
this scheme have begun use in case use session temporary storage. generating timestamp in js isn't secure, , whole things feels little... unstructured. there existing design pattern can use this, or more streamlined/secure approach? appreciated.
thanks.
you may take @ tempdata
stores data in session.when pull out of tempdata
removed after action done executing.
so, if put in tempdata
in action, live in tempdata
across other actions until requested tempdata
from tempdata again.
you can call tempdata.peek("key")
keep in memory until call tempdata["key"]
or tempdata.remove("key")
Comments
Post a Comment