Access Controller Context/ TempData from business objects
Posted
by
thanikkal
on Stack Overflow
See other posts from Stack Overflow
or by thanikkal
Published on 2011-03-05T15:09:00Z
Indexed on
2011/03/05
15:25 UTC
Read the original article
Hit count: 248
I am trying to build a session/tempdata provider that can be swapped. The default provider will work on top of asp.net mvc and it needed to access the .net mvc TempData from the business object class. I know the tempdata is available through the controller context, but i cant seem to find if that is exposed through HttpContext or something. I dont really want to pass the Controller context as an argument as that would dilute my interface definition since only asp.net based session provider needs this, other (using NoSQL DB etc) doesn't care about Controller Context.
To clarify further, adding little more code here. my ISession interface look like this. and when this code goes to production, the session/tempdata is expected to work using NoSql db. But i also like to have another implementation that works on top of asp.net mvc session/tempdata for my dev testing etc.
public interface ISession
{
T GetTempData<T>(string key);
void PutTempData<T>(string key, T value);
T GetSessiondata<T>(string key);
void PutSessiondata<T>(string key, T value);
}
© Stack Overflow or respective owner