Click or drag to resize

ServicePdfLiteSessionProvider Class

A service based implementation of the PdfLiteSessionProvider which uses the RAD PDF System Service for session management.
Inheritance Hierarchy

Namespace:  RadPdf.Lite
Assembly:  RadPdfStandard (in RadPdfStandard.dll) Version: 4.4.0.0 (4.4.0.0)
Syntax
public sealed class ServicePdfLiteSessionProvider : PdfLiteSessionProvider

The ServicePdfLiteSessionProvider type exposes the following members.

Constructors
  NameDescription
Public methodServicePdfLiteSessionProvider
Contructs a new ServicePdfLiteSessionProvider instance for use by RAD PDF.
Top
Methods
  NameDescription
Public methodAddSession
The default implementation of the PdfLiteSessionProvider which uses the ASP.NET Core Session State.
(Overrides PdfLiteSessionProviderAddSession(HttpContext, PdfLiteSession).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGenerateKey
Gets a string which contains a randomly generated key using RNGCryptoServiceProvider.
(Inherited from PdfLiteSessionProvider.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetSession
Gets a PdfLiteSession from the provider associated with a given key.
(Overrides PdfLiteSessionProviderGetSession(HttpContext, String).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

Session keys created and stored in the system service will expire automatically at the same rate as other cache (12 hours by default).

Examples
The following example overrides the default PdfIntegrationProvider to create a custom Integration Provider for the web application. This custom provider assigns ServicePdfLiteSessionProvider which uses the RAD PDF System Service for managing sessions.
C#
using System;
using System.Web;

using RadPdf.Integration;

public class CustomPdfIntegrationProvider : PdfIntegrationProvider
{
    public CustomPdfIntegrationProvider() : base()
    {
        this.LiteSessionProvider = new ServicePdfLiteSessionProvider();
    }
}
The following Program.cs file registers the above custom Integration Provider. This example assumes that CustomPdfIntegrationProvider is in namespace referenced by your ASP.NET web application.
C#
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();

// Setup WebApplication
var app = builder.Build();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();

// Or however you normally process page requests
app.MapRazorPages();

// Create middleware settings
RadPdfCoreMiddlewareSettings settings = new RadPdfCoreMiddlewareSettings()
{
    // Add License Key
    LicenseKey = "DEMO",

    // Attach the Integration Provider
    IntegrationProvider = new CustomPdfIntegrationProvider()
};

// Add RAD PDF's middleware to app
app.UseRadPdf(settings);

app.Run();
See Also