Click or drag to resize

PdfIntegrationProviderLiteSessionProvider Property

Gets or sets an object that specifies the session provider used for Lite Documents with RAD PDF applications using this integration provider.

Namespace:  RadPdf.Integration
Assembly:  RadPdf (in RadPdf.dll) Version: 3.48.0.0 (3.48.0.0)
Syntax
public PdfLiteSessionProvider LiteSessionProvider { get; set; }

Property Value

Type: PdfLiteSessionProvider
Remarks

The PdfLiteSessionProvider is responsible for associating a PdfLiteSession with a document key (string).

By default, RAD PDF uses the DefaultPdfLiteSessionProvider which uses the ASP.NET session state.

Examples
The following example overrides the default PdfIntegrationProvider to create a custom Integration Provider for the web application. This custom provider assigns a custom LiteSessionProvider which uses a simple dictionary.
C#
using System;
using System.Web;

using RadPdf.Integration;

public class CustomPdfIntegrationProvider : PdfIntegrationProvider
{
    public CustomPdfIntegrationProvider() : base()
    {
        this.LiteSessionProvider = new CustomPdfLiteSessionProvider();
    }
}
C#
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);
    }
}
The following web.config file registers the above custom Integration Provider. This example assumes that CustomPdfIntegrationProvider is in the directory App_Code of your ASP.NET web application.
XML
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="RadPdfLicenseKey" value="DEMO"/>
    <add key="RadPdfIntegrationProvider" value="CustomPdfIntegrationProvider,App_Code"/>
  </appSettings>
  <system.web>
    <httpHandlers>
      <add path="RadPdf.axd" verb="GET,POST" type="RadPdf.Web.HttpHandler.PdfHttpHandler"/>
    </httpHandlers>
  </system.web>
  <!--
    The system.webServer element is for use with IIS 7 (and later) when Managed Pipeline Mode is set to "Integrated".
    It will be ignored in other versions of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <add path="RadPdf.axd" verb="GET,POST" name="PdfHttpHandler" preCondition="integratedMode" type="RadPdf.Web.HttpHandler.PdfHttpHandler"/>
    </handlers>
  </system.webServer>
</configuration>
See Also