# Setup for ASP.NET MVC (OWIN)

## Content

## Introduction

This guide explains how to configure the Report Viewer middleware in an **ASP.NET MVC** (OWIN) application. You'll learn the necessary steps to install prerequisites, register services, and set up the middleware for report viewing.

## Prerequisites

Before configuring the middleware, ensure that the following are set up in your project:

1. **Install the required NuGet packages**:
    * [MESCIUS.ActiveReports.Aspnet.Viewer](https://www.nuget.org/packages/MESCIUS.ActiveReports.Aspnet.Viewer)
    * [Microsoft.Owin](https://www.nuget.org/packages/Microsoft.Owin/) (if not already installed)
2. **Add an OWIN Startup Class**:
    * If your application doesn’t already have a `Startup.cs` file, you can add one by following these steps:
        1. In **Visual Studio**, right-click on your project in **Solution Explorer**.
        2. Select **Add > New Item...**.
        3. Choose **OWIN Startup Class** from the list of templates.
        4. Name the file `Startup.cs` and click **Add**.
    * This automatically creates the `Startup` class for configuring OWIN middleware.

## Add Report Viewer Middleware

In **ASP.NET MVC**, middleware is configured using OWIN. Follow these steps to set up the Report Viewer middleware:

1. Open (or create) the `Startup.cs` file.
2. Add the Report Viewer middleware to the request pipeline by calling `UseReportViewer`.
3. Update your `web.config` to handle URL patterns by setting `requestPathInvalidCharacters=""` and `allowDoubleEscaping="true"`.

## Example Configuration

Here’s an example of configuring OWIN middleware in `Startup.cs`:

```csharp
using Owin;
using MESCIUS.ActiveReports.Aspnet.Viewer;

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        // Handle application-level errors
        app.UseErrorPage();

        // Add Report Viewer middleware
        app.UseReportViewer(settings =>
        {
            // Configure the Report Viewer here (optional)
        });

        // Ensure route handling works for existing files
        RouteTable.Routes.RouteExistingFiles = true;
    }
}
```

After adding the Report Viewer middleware, the next step is to configure it to meet your application’s needs. For a complete guide on the available configuration options, continue to the [Middleware Configuration Options](/activereportsnet/docs/developers/create-applications/web-viewer-and-web-designer-middlewares/jsvieweraspnet-middleware/middleware-configuration-options).