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
- Download the project or clone the repository
- Open the project folder (
dotnet\mvc
) - Open the solution file (.sln) on Visual Studio
- Generate an API access token on the REST PKI website
- Paste your access token on the file
web.config
- 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:
PAdES signature with file already on server
- Controller: PadesSignatureRestController
- Views:
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:
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:
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:
XML signature of an element
- Controller: XmlNFeSignatureRestController
- Views:
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.