Reputation: 241
What's the best way to display ALL session variables on a .cshtml page?
Tried using
@HttpContext.Current.Session();
But that didn't show anything.
Upvotes: 4
Views: 5791
Reputation: 16743
This is untested, but should work:
@{ var session = HttpContext.Current.Session; }
@foreach (string key in session.Keys) {
<p>Key: @key - Value: @session[key].ToString()</p>
}
Upvotes: 6