DefaultPdfLiteSessionProvider Class |
Namespace: RadPdf.Lite
The DefaultPdfLiteSessionProvider type exposes the following members.
Name | Description | |
---|---|---|
![]() | DefaultPdfLiteSessionProvider |
Constructs a new DefaultPdfLiteSessionProvider instance for use by RAD PDF.
|
Name | Description | |
---|---|---|
![]() | AddSession |
Adds a new PdfLiteSession to the provider.
(Overrides PdfLiteSessionProvider.AddSession(HttpContext, PdfLiteSession).) |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GenerateKey |
Gets a string which contains a randomly generated key using RNGCryptoServiceProvider.
(Inherited from PdfLiteSessionProvider.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetSession |
Gets a PdfLiteSession from the provider associated with a given key.
(Overrides PdfLiteSessionProvider.GetSession(HttpContext, String).) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | RemoveSession |
Removes an existing PdfLiteSession in the provider.
|
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | UpdateSession |
Updates an existing PdfLiteSession in the provider.
|
using System; using System.Collections.Concurrent; using System.Web; using RadPdf.Lite; public class CustomPdfLiteSessionProvider : PdfLiteSessionProvider { // This example uses an in memory dictionary, which won't have // persistent storage, but a database or other key /value store // can easily be substituted. private readonly ConcurrentDictionary<string, byte[]> _dict; public CustomPdfLiteSessionProvider() : base() { _dict = new ConcurrentDictionary<string, byte[]>(); } public override string AddSession(PdfLiteSession session) { string key = GenerateKey(); _dict[key] = session.Serialize(); return key; } public override PdfLiteSession GetSession(string key) { byte[] data = _dict[key]; if (null == data) { return null; } return PdfLiteSession.Deserialize(data); } }
using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using RadPdf; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddSession(); // This is important! Add the built in ASP.NET Session manager // Learn more: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state // Setup WebApplication var app = builder.Build(); app.UseStaticFiles(); app.UseRouting(); app.UseSession(); // This is important! Add the built in ASP.NET Session Manager app.UseAuthorization(); // Or however you normally process page requests app.MapRazorPages(); // Create middleware settings RadPdfCoreMiddlewareSettings settings = new RadPdfCoreMiddlewareSettings() { // Add License Key LicenseKey = "DEMO", // No need to attach the Integration Provider! // The default one is already attached and uses the ASP.NET Session Manager // IntegrationProvider = new DefaultPdfIntegrationProvider() // To run RAD PDF without the System Service, add UseService = false // If using Lite Documents without the System Service, a LiteStorageProvider must also be implemented //UseService = false }; // Add RAD PDF's middleware to app app.UseRadPdf(settings); app.Run();