• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

NCache as ITicketStore Provider

The NCache ITicketStore integration provides a distributed backing store for ASP.NET Core Cookie Authentication through the ITicketStore interface. It allows ASP.NET Core applications to store complex user identity structures (authentication tickets) in NCache so that authenticated sessions can be shared across multiple application instances in a load-balanced environment.

NCache ITicketStore integration can be configured using the following approaches:

  • Using appsettings.json (Recommended for Production)

  • Using an Action Delegate in Program.cs

Both approaches require a custom implementation of the ITicketStore interface to map ASP.NET Core authentication middleware lifecycle events directly to NCache client commands.

Note

This feature is supported only in the NCache OpenSource edition.

Important

ITicketStore is supported in NCache OSS 5.3.6.2 and later.

Prerequisites

Before configuring ASP.NET Core ITicketStore with NCache, ensure that the following prerequisites are fulfilled:

  • .NET
  • To configure ASP.NET Core ITicketStore with NCache, install the following NuGet package in your .NET application:
    • OpenSource: NCache.OSS.AspNetCore.Authentication.TicketStore
  • To utilize the ITicketStore provider, include the following namespaces in your application in Program.cs:
    • NCache.OSS.AspNetCore.Authentication.TicketStore
    • Microsoft.AspNetCore.Authentication
    • Microsoft.AspNetCore.Authentication.Cookies
    • System.Security.Claims
  • The cache must be running.

Method 1: Using appsettings.json (Recommended)

This approach stores TicketStore provider settings inside appsettings.json and binds them automatically through IConfiguration during application startup. It is useful for environments where configuration values may change between deployments because cache settings can be modified without changing application code. This is the recommended approach for production environments because configuration changes can be made without recompiling the application.

In this configuration approach, NCache connection settings are defined inside appsettings.json while your initialization code reads and binds the configuration section manually during service registration into the dependency injection container.

Step 1: Configure NCache Settings

The following configuration defines the NCache cache name and server connectivity information used by the TicketStore provider. Add the following configuration section in your appsettings.json file.

{
  "NCacheTicketStore": {
    "CacheName": "demoCache",
    "ServerList": [
      {
        "Ip": "20.200.20.29",
        "Port": 9800
      }
    ]
  }
}

Step 2: Register the Configuration Section

After defining the NCache settings in appsettings.json, register the custom NCache TicketStore provider by binding it to the NCacheTicketStore configuration section. When a user authenticates via the /login endpoint, their full identity context is safely externalized to the NCache distributed cluster while the client browser receives a minimal session cookie wrapper.

Add the following code in your Program.cs file.

builder.Services.AddNCacheTicketStore(
    builder.Configuration.GetSection("NCacheTicketStore"));

Method 2: Using an Action Delegate in Program.cs

In this approach, the TicketStore provider configuration is defined directly inside Program.cs through an action delegate passed to AddNCacheTicketStore. The action delegate allows the cache name and server connectivity parameters to be configured programmatically during application initialization.

The following configuration registers the custom NCache TicketStore provider using an inline action delegate, defining the target cache instance and populating the server connection list directly within the application startup routines.

Add the following code in your Program.cs file.

builder.Services.AddNCacheTicketStore(options =>
    {
        options.CacheName = "demoCache";

        options.ServerList.Add(new NCacheOptions.ServerConfig
        {
            Ip = "20.200.20.29",
            Port = 9800
        });
    });

Configuration Properties

The following configuration properties are available in the NCacheOptions class.

Note

Properties marked with an asterisk (*) are required. All other properties are optional.

Property Description
CacheName* Specifies the name of the NCache cache instance. The cache must already exist in the NCache cluster and is required for provider initialization.
ServerList Specifies the list of NCache server nodes used for cache connectivity. Each ServerConfig entry contains an IP address and port number. IP addresses must be valid IPv4 or IPv6 addresses and port values must be between 1–65535.

See Also

ASP.NET Core ITicketStore with NCache

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top