Add e-signatures and clickwrap to .NET
To add e-signatures and clickwrap to .NET, call the REST API from ASP.NET Core with HttpClient: there is no NuGet package, because the server SDK exists for Node.js only. One minimal API route creates the session with the secret key, session state holds the pinned versions, and another route confirms the record. Esign Comply seals each acceptance.
Follow the quickstart and each signature is a valid electronic signature under the U.S. ESIGN Act, state UETA laws and New York's ESRA, and each clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.
No package to install: HttpClient and System.Text.Json are enough
.NET quickstartFree plan: 10 live signatures a month and a full test mode. No card required.
Last updated
// Step 4: create the session with the secret key. The browser gets the client token only. app.MapPost("/api/ceremony", async (HttpContext context, EsignComply esc) => { // The page that runs the ceremony: the origin the browser reports, or the scheme and host ASP.NET Core saw. var origin = context.Request.Headers.Origin.FirstOrDefault() ?? $"{context.Request.Scheme}://{context.Request.Host}"; var (status, created) = await esc.Call<Session>(HttpMethod.Post, "sessions", new { Profile = config["ESIGNCOMPLY_PROFILE_ID"], Signer = signer, Documents = new[] { new { Document = documents["terms"], Version = "current" }, new { Document = documents["privacy"], Version = "current" }, }, Context = new { Url = $"{origin}/signup", Locale = "en-US", Purpose = "account_signup" }, }, idempotencyKey: $"signup-{signer.ExternalId}-{Guid.NewGuid():N}"); if (status != 201 || created is null) return Results.Json(new { error = created?.Error?.Code ?? "unknown" }, statusCode: 502); var versionIds = created.Documents.EnumerateArray().Select(d => d.GetProperty("version_id").GetString()).Order(); context.Session.SetString("signer_id", signer.ExternalId); context.Session.SetString("version_ids", string.Join(",", versionIds)); // The documents go to the browser as the API sent them: a JsonElement is written unchanged. return Results.Json(new { clientToken = created.ClientToken, apiUrl = created.ApiUrl, documents = created.Documents }); });
/// <summary>One call to the Esign Comply API. Returns the HTTP status and the JSON answer.</summary> class EsignComply(HttpClient http) { // The API's fields are snake_case. The web defaults look for clientToken, find nothing and leave null. static readonly JsonSerializerOptions Json = new(JsonSerializerDefaults.Web) { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }; public async Task<(int Status, T? Body)> Call<T>(HttpMethod method, string path, object? body = null, string? idempotencyKey = null) { for (var attempt = 1; ; attempt++) { // A request message is sent once, so each attempt builds its own. using var request = new HttpRequestMessage(method, path); // no leading slash: the path is relative to BaseAddress if (body is not null) request.Content = JsonContent.Create(body, options: Json); if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey); using var response = await http.SendAsync(request); // Rate limited: wait for the seconds in Retry-After, 1 at least and 5 at most, and send it again, twice at most. if ((int)response.StatusCode == 429 && attempt < 3) { var seconds = response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 1; await Task.Delay(TimeSpan.FromSeconds(Math.Clamp(seconds, 1, 5))); continue; } // SendAsync does not throw on 4xx and 5xx: the status is here, and the error envelope is the body. return ((int)response.StatusCode, await response.Content.ReadFromJsonAsync<T>(Json)); } } }
// Step 6: confirm the record with the secret key before the account exists. app.MapPost("/api/signup/confirm", async (ConfirmRequest body, HttpContext context, EsignComply esc) => { var (status, record) = await esc.Call<SignatureRecord>(HttpMethod.Get, $"records/{Uri.EscapeDataString(body.RecordId ?? "missing")}"); var confirmed = status == 200 && record?.Documents is not null && sealedStatuses.Contains(record.Status) && record.Livemode == live && context.Session.GetString("signer_id") is { } signerId && record.Signer?.ExternalId == signerId && context.Session.GetString("version_ids") == string.Join(",", record.Documents.Select(d => d.VersionId).Order()); if (!confirmed) { app.Logger.LogInformation("refused"); return Results.Json(new { confirmed = false }, statusCode: 409); } app.Logger.LogInformation("confirmed {Id} ({Status})", record!.Id, record.Status); // Only now create the account, and store record.Id and the record's receipt with it. return Results.Json(new { confirmed = true, recordId = record.Id }); });
// There is no .NET package: these are plain HTTPS calls with the secret key, through IHttpClientFactory. builder.Services.AddHttpClient<EsignComply>(client => { // The trailing slash matters: without it HttpClient drops "/v1" from every address. client.BaseAddress = new Uri((config["ESIGNCOMPLY_API_URL"] ?? "https://esigncomply.com/v1").TrimEnd('/') + "/"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", config["ESIGNCOMPLY_API_KEY"]); client.Timeout = TimeSpan.FromSeconds(10); }); // Server-owned state: ASP.NET Core's session. The data stays in the memory of this process, // and the browser holds only the session ID, in a cookie that Data Protection encrypts. builder.Services.AddDistributedMemoryCache(); builder.Services.AddSession(options => { options.Cookie.HttpOnly = true; options.Cookie.SameSite = SameSiteMode.Lax; options.Cookie.SecurePolicy = live ? CookieSecurePolicy.Always : CookieSecurePolicy.SameAsRequest; options.Cookie.IsEssential = true; }); var app = builder.Build();
How do you integrate Esign Comply with .NET?
In ASP.NET Core the integration is one Program.cs of minimal API routes. A typed HttpClient from IHttpClientFactory makes the calls, JsonNamingPolicy.SnakeCaseLower maps the API's fields onto C# records, and session state keeps the pinned versions on the server. The page is a file in wwwroot.
.NET is the free, open-source, cross-platform framework for building modern apps and powerful cloud services.
Source: dotnet.microsoft.com, read on .- Session routeProgram.cs
- The API callProgram.cs
- Confirm routeProgram.cs
- ServicesProgram.cs
Run on 2026-11-26 with ASP.NET Core 10.0.15 minimal APIs on .NET 10, the current LTS release (SDK 10.0.404), HttpClient through IHttpClientFactory and no NuGet package, under dotnet run and as a published app (in Microsoft's SDK container image), with the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode.
What prompt adds Esign Comply clickwrap to a .NET app?
Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes in .NET, what to build and what never to do, and it ends with the rules block for your project.
The rules block lives at /rules.md. Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The prompt generator writes the long version, with your own document and profile IDs.
Pages for each AI toolAdd Esign Comply clickwrap to my .NET app: a signup form where the user accepts the Terms of Service and the Privacy Notice with a checkbox and a button.
Read these first and follow them exactly. If something conflicts with existing code, or you are unsure how to implement a step, stop and ask. Do not invent API methods, packages or legal wording.
- https://esigncomply.com/docs/quickstart/dotnet.md (the steps and the tested code for .NET)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)
.NET facts
- There is no Esign Comply package for .NET. Do not install or invent one. The server calls the REST API at https://esigncomply.com/v1 with Authorization: Bearer and the secret key, using an HttpClient from IHttpClientFactory.
- The browser SDK is a script tag: https://esigncomply.com/sdk/v1/esigncomply.js. It defines the global EsignComply.
- The secret key is the configuration value ESIGNCOMPLY_API_KEY: an environment variable, or a user secret in the Development environment. Never put it in appsettings.json or in launchSettings.json. Never print the key.
- HttpClient.BaseAddress must end with a slash and the paths must not start with one, or "/v1" is dropped from every address.
- The API's JSON is snake_case. Read and write it with JsonNamingPolicy.SnakeCaseLower: with the web defaults a typed read leaves client_token null and throws nothing. Send the documents to the browser as the API sent them.
- SendAsync does not throw on 4xx and 5xx, and GetFromJsonAsync does. Check the status code before you read the record.
- Keep the signer ID and the pinned version IDs in ASP.NET Core session state (AddDistributedMemoryCache, AddSession, UseSession), or in the store the project already has.
- Return the document HTML with Results.Content and the content type text/html, unmodified. A string returned from a handler is sent as text/plain.
- Minimal APIs do not validate an antiforgery token on a POST that carries JSON. If the project validates one on its API routes, send the token with both POST requests.
- The page is on screen before the script has a session: render the checkbox disabled and enable it when observeAssent has resolved.
Build
1. Verify the key: GET /v1/usage with ESIGNCOMPLY_API_KEY. Stop if it fails.
2. Register the Terms of Service and the Privacy Notice as documents and publish one version of each from the documents in this project. If the project has none, register short sample documents and say so in your report. Never write or change the wording of the real documents. Create a profile: jurisdictions ["US-FED"], method "checkbox", assurance_level "L1".
3. Route for POST /api/ceremony: call POST /v1/sessions with an Idempotency-Key, save the signer ID and the pinned version IDs in session state, and return only clientToken, apiUrl and documents.
4. Route for GET /legal/{slug}: render the html from GET /v1/documents/{id}/versions/{version_id}/content inside <article data-esc-document>, unmodified.
5. Browser: EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }), then complete() from the user's real click.
6. Route for POST /api/signup/confirm: call GET /v1/records/{id} and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the ones in session state. Only then create the account.
Never
- Never pre-check the box, auto-submit, or call .click() on the user's behalf.
- Never use "By continuing" or "By clicking below" wording. The notice names the button by its label and each document by its registered name.
- Never put the secret key, or any call that uses it, in code that reaches the browser.
- Never show "signed" or "accepted" before the server has confirmed the record.
- Never fall back to an acceptance with no record when a session is refused.
Check before you report success
- Run: npx esigncomply check --url http://localhost:5000/signup --callback http://localhost:5000/api/signup/confirm
Fix every finding marked "block". List every finding marked "warn".
- Report the files you created or changed, anything you did not implement and why, and the conformance summary.
Then add the rules block to this project's instruction file: https://esigncomply.com/rules.mdWhat goes wrong when you add e-signatures in .NET?
These are specific to .NET. Each one was seen while the quickstart's code was run, or is in .NET's own documentation.
- 01
HttpClient drops /v1 unless BaseAddress ends with a slash
The
Source: Microsoft Learn, HttpClient.BaseAddress Property, read on .HttpClient.BaseAddressdocumentation says all characters after the right-most/in the base URI are excluded when it is combined with the message URI. In the test on .NET 10, three of four combinations of base and path asked for/usagewithout/v1and got404. The quickstart ends the base with a slash and starts each path without one. - 02
System.Text.Json reads snake_case fields as null without an error
Microsoft's documentation says the web default naming policy is camel case. In the test the API's answer read into a C# record with
Source: Microsoft Learn, System.Text.Json property names, read on .ClientTokenandApiUrlleftnulland nothing thrown, andResults.JsonwroteversionIdwhere the page readsversion_id. The quickstart setsJsonNamingPolicy.SnakeCaseLowerand passes the documents through as aJsonElement. - 03
launchSettings.json wins over your shell, and is not published
Microsoft's documentation says environment values set in
Source: Microsoft Learn, ASP.NET Core runtime environments, read on .launchSettings.jsonoverride values set by the system environment, and that the file isn't deployed when the app is published. In the test a setting in that file won over the same variable in the shell underdotnet run. Without the launch profile the app ran asProductionand read no user secret. Keep the key in the environment or in user secrets.
Where are the .NET quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- Quickstart.NET quickstartStep by step, from install to your first sealed test record, with every file and the output of each step.Open
- ReferenceAPI referenceEvery endpoint, field and error code. Sessions, records and documents are the three this page uses.Open
- GuideServer confirmationThe one place access is granted: what to compare, and the webhook that backs the check up.Open
What does Esign Comply record for a signature in .NET?
The same record on every stack and platform. Your .NET code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on Evidence and verification.
Observed and asserted fields
Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.
A signed receipt
complete()returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, andGET /v1returns it again./records /{id} /receipt An external timestamp
An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.
An offline verifier
Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source
esigncomply-verify, without an account.
Questions about e-signatures in .NET
Is there an Esign Comply SDK for .NET?
No. The server SDK exists for Node.js only, and there is no NuGet package. An ASP.NET Core app calls the REST API directly with the secret key, and the quickstart does it with HttpClient from IHttpClientFactory and System.Text.Json. The browser side is the same SDK as on every stack.
Where do I create the session in .NET?
In a minimal API route, app.MapPost for /api, with a POST to /v1 that carries the secret key and an Idempotency-Key. The route saves the pinned versions in session state and returns only the client token, the API URL and the documents.
Do minimal APIs validate an antiforgery token on these routes?
No. In the test a JSON POST with no token and the Origin of another site ran the handler, even with UseAntiforgery and RequireAntiforgeryToken on the route. Microsoft's documentation says the middleware does not short-circuit the pipeline. Only IAntiforgery.ValidateRequestAsync in the handler refused the request. Here the confirmation check is what refuses a forged call.
Does ASP.NET Core session state survive a restart?
No. Session state is in the memory of the process, and its cookie is encrypted with Data Protection keys. After a restart the same cookie was answered 409 in the test, and a cookie from a removed container could not be decrypted. With more than one instance, keep the pinned versions in your database.
Does the published app behave like dotnet run?
No, in three ways seen in the test. It ran in the Production environment, it had no launchSettings.json and took its address from --urls, and it used the folder it was started in as content root: started elsewhere, /signup answered 500. Started from its own folder it recorded a signature.
Call the API from the ASP.NET Core app you already run. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.
.NET is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about .NET is from .NET's documentation or from a test run, as marked, on . /dotnet.md is this page as Markdown.