Skip to content

Extension methods for helping deal with complex types for TempData and Session.

License

Notifications You must be signed in to change notification settings

dburriss/BetterSession.AspNet.Mvc

Repository files navigation

BetterSession

Extension methods for helping deal with complex types for TempData and Session.

DEV MASTER BLEEDING NUGET
CI status Release Build status MyGet CI NuGet CI

Usage

Session

The ISession has a void Set<T>(string key, T value) and T Get<T>(string key) methods.

using BetterSession.AspNetCore.Http;

var model = new TestModel()
{
    Nr = 1,
    Name = "D"
};
session.Set("t", model);
var value = session.Get<TestModel>("t");

TempData

The ITempDataDictionary has a void Set<T>(string key, T value) and T Get<T>(string key) methods.

using BetterSession.AspNetCore.Mvc;

var model = new TestModel()
{
    Nr = 1,
    Name = "D"
};
tempData.Set("t", model);
var value = tempData.Get<TestModel>("t");

About

Extension methods for helping deal with complex types for TempData and Session.

Resources

License

Stars

Watchers

Forks

Packages

No packages published