Last time, I wrote about digital signatures, how to set up DocuSign to manage digitally signing documents, and wrote some C# code to allow this DocuSign process to be built into a custom C# application.

This time I want to write about how to integrate this with a .NET MVC website.

I’d normally use .NET Core these days – however, the DocuSign SDK is written for the .NET Framework so I’ll use that. If your website is already in .NET Core, it would be possible to put the DocuSign functions into a .NET Framework RESTful API, and then access this API from a .NET Core MVC site.

I created the baseline MVC application using Visual Studio 2017 (and I’ve pushed the finished code to GitHub here).

My intention is to customise this to show:

  • A list of documents which have been generated with my profile, and their statuses, and
  • A page for a user to enter in a name and an email address, and generate a document.

Create a class to list the DocuSign envelopes my profile has sent.

This is straightforward (when you know how!) – you can list envelopes using the ListStatusChanges method of the EnvelopesApi object. If we know profile’s Account Id, we can specifiy options (such as the number of envelopes to return, and the earliest envelope date we’re interested in) and use these options to list the envelopes sent.

var fromDate = DateTime.UtcNow;
fromDate = fromDate.AddDays(-30);
string fromDateStr = fromDate.ToString("o");
// set a filter for the envelopes we want returned using the fromDate and count properties
var options = new EnvelopesApi.ListStatusChangesOptions()
        count = numberOfItems.ToString(),
        fromDate = fromDateStr
EnvelopesApi envelopesApi = new EnvelopesApi();
return envelopesApi.ListStatusChanges(accountId, options).Envelopes;

I put this code into a class named DocuSignProfile and a method called ListEnvelopes – you can see the complete file at GitHub here.

This makes it very easy to get a list of 10 Envelopes in my controller and pass them to the view, as shown below (the GetDocuSignCredentials() method just gets an object with my username, password and integrator key – you can see the details in the source code.).

public ActionResult Index()
    var myProfile = new DocuSignProfile(GetDocuSignCredentials());
    return View(myProfile.ListEnvelopes(10));

The project now shows this table on the home page, as shown below. You can see the items which have been digitally signed and returned with the status “completed” – the other documents which have been sent but the recipient hasn’t signed yet have the status “sent”.


When I click on the “Create a Document” button, it takes me to a page which allows me to enter a name and email address.


When I enter a name and email, and then click on Generate Document, it sends an email to the address specified on the page above with a request to sign a digital document.I’ve described the process of how a recipient signs a document here, so I won’t repeat it again in this post.

The code at GitHub is proof-of-concept and follows a happy path, it isn’t robust and won’t handle errors well (like leaving fields blank) – it’s just intended to be the bare minimum example code needed to demonstrate how to integrate DocuSign with a website.


In the last couple of posts, I’ve written about how to use DocuSign to generate documents to be digitally signed by a recipient, and how to integrate this off-the-shelf solution with a C# MVC website. I hope this helps anyone working with DocuSign and C#.

I’ve pushed the source code to my GitHub repository here. All passwords and keys should be stored in the web.config file (I’ve deleted my keys obviously).