---
title: "Integration Guide on .NET"
description: "Integrating a .NET application with the Lacuna Scanner Service using the Lacuna.Scanner.Client package: creating the ScannerClient and scan sessions."
canonical: "https://docs.lacunasoftware.com/en-us/articles/scanner/integration/dotnet"
locale: "en"
product: "Scanner"
last_updated: "2026-10-12"
---

# Integration Guide on .NET

To integrate your .NET web application with the [Lacuna Scanner Service](https://docs.lacunasoftware.com/en-us/articles/scanner), follow the steps in this article.

> **Tip**
>
> Before you start, see the [integration overview](https://docs.lacunasoftware.com/en-us/articles/scanner/integration#overview).

First, add the [Lacuna.Scanner.Client](https://www.nuget.org/packages/Lacuna.Scanner.Client) package to your project.

> **Tip**
>
> If your application uses ASP.NET Core, see the [ASP.NET Core](https://docs.lacunasoftware.com/en-us/articles/scanner/integration/dotnet#aspnet-core) section below.

With the **endpoint** and the **API Key** at hand, create a `ScannerClient`:

```cs
var endpoint = "...";
var apiKey = "...";
var scanner = new ScannerClient(endpoint, apiKey);
```

Call the `CreateScanSessionAsync(string)` method, passing the **returnUrl**, to start a session:

```cs
var scanSessionParams = await scanner.CreateScanSessionAsync("https://your-return-url/");
```

> **Note**
>
> For backward compatibility, sessions created as above (with only the *returnUrl*) require the metadata input and document signature
> steps.

Or, if you want more control over the session options:

```cs
var scanSessionParams = await scanner.CreateScanSessionAsync(new CreateScanSessionRequest2() {
	ReturnUrl = "https://your-return-url/",
	MetadataInputEnabled = ...,
	SignatureEnabled = ...,
});
```

Use the value returned in the `RedirectUrl` field to redirect the user on the frontend:

```js
location.href = scanSessionParams.RedirectUrl;
```

When you detect that the user has returned to your site (look for the `scanSessionId` argument in the URL), call the `GetScanSessionAsync(Guid)` method to get the
scanned documents:

```cs
var scanSession = await scanner.GetScanSessionAsync(scanSessionId);
if (scanSession.Result == ScanSessionResults.Success) {
	var document = scanSession.Documents.First();
	using (var srcStream = await document.OpenReadAsync()) {
		using (var destStream = File.Create(...)) {
			await srcStream.CopyToAsync(destStream);
		}
	}
}
```

## Multifile sessions

You can let the user scan multiple documents. To do so, pass the `multifile: true` parameter when creating the session:

```cs
var scanSessionParams = await scanner.CreateScanSessionAsync("https://your-return-url/", multifile: true);
```

At the end of the process, instead of taking only the first document, iterate over the list of scanned documents:

```cs
var scanSession = await scanner.GetScanSessionAsync(scanSessionId);
if (scanSession.Result == ScanSessionResults.Success) {
	foreach (var document in scanSession.Documents) {
		...
	}
}
```

## Sessions with metadata input and/or signature

To ask the person scanning to enter the metadata required by Decree 10,278/2020, set the `MetadataInputEnabled = true` property:

```cs
var scanSessionParams = await scanner.CreateScanSessionAsync(new CreateScanSessionRequest2() {
	ReturnUrl = "https://your-return-url/",
	MetadataInputEnabled = true,
});
```

> **Note**
>
> The `Lacuna.Scanner.Client` package must be version **1.3.0** or later.

To have the person scanning digitally sign the document at the end of the process, set the `SignatureEnabled = true` property:

```cs
var scanSessionParams = await scanner.CreateScanSessionAsync(new CreateScanSessionRequest2() {
	ReturnUrl = "https://your-return-url/",
	SignatureEnabled = true,
});
```

> **Tip**
>
> To comply with Decree 10,278/2020, enable both metadata input and document signature.

## ASP.NET Core

If your web application uses ASP.NET Core, add the following to the `ConfigureServices` method of your application's *startup*:

```cs
public void ConfigureServices(IServiceCollection services) {
	...
	services.AddScanner()
		.Configure(Configuration.GetSection("Scanner"));
}
```

> **Note**
>
> Don't use the ~~Lacuna.Scanner.Client.AspNetCore~~ package. The [Lacuna.Scanner.Client](https://www.nuget.org/packages/Lacuna.Scanner.Client) package
> already has everything you need to use the Scanner in ASP.NET Core.

In the `appsettings.json` configuration file, add the **Scanner** section:

```json
...
"Scanner": {
	"Endpoint": "https://scn.lacunasoftware.com/",
	"ApiKey": "..."
},
...
```

In the parts of the application that need to call the service API, request an instance of `IScannerService` through dependency injection:

```cs
using Lacuna.Scanner.Client;

public class MyController : ControllerBase {

	private readonly IScannerService scanner;

	public MyController(IScannerService scanner) {
		this.scanner = scanner;
	}

	...
}
```
