This project contains a Sitecore pipeline processor and extensions to the HttpRouteCollection
to enable session in Web API 2.
- Add Sitecore's NuGet repository added to Visual Studio.
- Build the solution and add
WebApiEnableSessionHandler.dll
as a reference to your Web API 2 projects. - Deploy
WebApiEnableSessionHandler.config
intoApp_Config\Include\zzz.WebApiEnableSessionHandler
. Ensure thatWebApiEnableSessionHandler.Pipelines.InitializeSessionEnabledRouteHandlers
is one of the last processors in theinitialize
pipeline. - Use
config.Routes.AddHttpSessionRoute()
in your Web API initialization to register session-enabled routes. SetreadOnlySession
tofalse
for routes that only need read access to session; set it totrue
for routes that need read and write access to session.