Show / Hide Table of Contents
Edit on GitHub

ASP.NET MVC samples project

The ASP.NET MVC samples project shows how to use Rest PKI together with Web PKI on a project using ASP.NET MVC 5. It is hosted on GitHub at:

https://github.com/LacunaSoftware/PkiSuiteSamples/tree/master/dotnet/mvc

Running the project

  1. Download the project or clone the repository
  2. Open the project folder (dotnet\mvc)
  3. Open the solution file (.sln) on Visual Studio
  4. Generate an API access token on the REST PKI website
  5. Paste your access token on the file web.config
  6. Run the solution. Make sure your system allows automatic Nuget package restore (if it doesn't, manually restore the packages).

Project map

This section lists where to find the relevant parts in each feature sample on the project.

Authentication with digital certificate

  • Controller: AuthenticationRestController
  • Views:
    • AuthenticationRest/Index.cshtml (JavaScript on signature-form.js)
    • AuthenticationRest/Failed.cshtml
    • AuthenticationRest/Success.cshtml

PAdES signature with file already on server

  • Controller: PadesSignatureRestController
  • Views:
    • PadesSignatureRest/Index.cshtml (JavaScript on signature-form.js)
    • PadesSignatureRest/SignatureInfo.cshtml

PAdES signature with file uploaded by user

After the file upload (which is crudely implemented merely for demonstration purposes on the controller UploadController and view Upload/Index.cshtml) is done the control flow is the same as in the sample PAdES signature with file already on server, but with the URL parameter userfile filled.

PAdES co-signature

After the control flow of the sample PAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter userfile filled.

PAdES marks

This feature is demonstrated as an optional configuration on the PAdES signature with file already on server sample which by default starts commented out. To enable it, uncomment the following line on PadesSignatureController:

signatureStarter.PdfMarks.Add(PadesVisualElements.GetPdfMark(1));
Tip

Try changing the argument to the GetPdfMark(int) method to see different PDF mark configurations

The relevant code is on the class PadesVisualElements, method GetPdfMark(int).

PAdES signature without client communication

  • Controller: PadesSignatureWithoutDirectCommunicationControlller
  • Views:
    • PadesSignatureWithoutDirectCommunication/Index.cshtml (JavaScript on signature-start-form.js)
    • PadesSignatureWithoutDirectCommunication/Complete.cshtml (JavaScript on signature-complete-form.js)
    • PadesSignatureWithoutDirectCommunication/SignatureInfo.cshtml

Open/validate an existing PAdES signature

  • Controller: OpenPadesSignatureRestController
  • View: OpenPadesSignatureRest/Index.cshtml

Printer-friendly version

  • Controller: PrinterFriendlyPadesRestController

CAdES signature with file already on server

  • Controller: CadesSignatureRestController
  • Views:
    • CadesSignatureRest/Index.cshtml (JavaScript on signature-form.js)
    • CadesSignatureRest/SignatureInfo.cshtml

CAdES signature with file uploaded by user

After the file upload (which is crudely implemented merely for demonstration purposes on the controller UploadController and view Upload/Index.cshtml) is done the control flow is the same as in the sample CAdES signature with file already on server, but with the URL parameter userfile filled.

CAdES co-signature

After the control flow of the sample CAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter cmsfile filled.

Open/validate an existing CAdES signature

  • Controller: OpenCadesSignatureRestController
  • View: OpenCadesSignatureRest/Index.cshtml

XML signature of the entire document

  • Controller: XmlSignatureRestController
  • Views:
    • XmlSignatureRest/Index.cshtml (JavaScript on signature-form.js)
    • XmlSignatureRest/SignatureInfo.cshtml

XML signature of an element

  • Controller: XmlNFeSignatureRestController
  • Views:
    • XmlNFeSignatureRest/Index.cshtml (JavaScript on signature-form.js)
    • XmlNFeSignatureRest/SignatureInfo.cshtml

Open/validate signatures on an existing XML file

  • Controller: OpenXmlSignatureRestController
  • View: OpenXmlSignatureRest/Index.cshtml

Batch of PAdES signatures

  • Controller: BatchPadesSignatureRestController
  • View: BatchPadesSignatureRest/Index.cshtml (JavaScript on batch-signature-rest-form.js)

Optimized batch of PAdES signatures

  • Controller: BatchSignatureOptimizedController
  • View: BatchSignatureOptimized/Index.cshtml (JavaScript on batch-signature-optimized-form.js)

Batch of CAdES signatures

  • Controller: BatchCadesSignatureRestController
  • View: BatchCadesSignatureRest/Index.cshtml (JavaScript on batch-signature-rest-form.js)

Batch of XML signatures of elements on the same document

Not yet available on this project.

Back to top Copyright © 2015-2020 Lacuna Software