c# - MVC HttpContext.Current.Items is null after clicking a link -
is there limitation httpcontext.items ? if alternative?
in firstcontroller index view setting item.
public class firstcontroller : controller { public actionresult index() { httpcontext.items["sample"] = "data"; return view(); } } <a href="/secondcontroller/testview">sample link</a>
when try value in secondcontroller giving me null instead of 'data'
public class secondcontroller : controller { public actionresult testview() { string text = httpcontext.current.items["sample"]; return view(); } }
httpcontext.items
"gets key/value collection can used organize , share data [...] during http request".
you need stateful mechanism session preserve data between requests:
session["sample"] = "data";
see what correct way of storing data between requests in asp.mvc .
Comments
Post a Comment