# ASP.NET Core Applications

> Publish an ASP.NET Core app with the TX Sheet Control Tag Helper: the static web assets in _content, UseStaticFiles or MapStaticAssets, path bases and checks.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Deployment Guide > ASP.NET Core Applications
- **1370 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/aspnet-core/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/aspnet-core/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/aspnet-core/llms-full.txt

---

A Razor Pages or MVC application shows the spreadsheet editor with the Tag Helper of the package `TXTextControl.TXSheetControl.AspNetCore`. The package brings the editor script and its fonts as static web assets: `dotnet publish` copies them into the output, and the static file middleware of the application serves them. Backend processing needs the separate Server package, `TXTextControl.TXSheetControl.Server`; the editor does not.

### Configure the Middleware

The application serves the editor's files with the ordinary static file middleware:

```csharp
using TXTextControl.TXSheetControl.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();

var app = builder.Build();
app.UseTXSheetControlAssets();
app.UseStaticFiles();
app.MapRazorPages();
app.Run();
```

- **Static files.** `UseStaticFiles` serves the editor's files. The `MapStaticAssets` call of the .NET 10 project templates works as well; keep the one your project uses.
- **[UseTXSheetControlAssets](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-aspnetcore/txsheetcontrolassetextensions/usetxsheetcontrolassets-method/llms-full.txt).** Call it before `UseStaticFiles` or `MapStaticAssets`. It rejects requests for private and debugging paths of the package before the static file middleware answers them. It does not serve files itself: without static files, the editor's scripts return 404.
- **`UseStaticWebAssets`.** A published application does not need `builder.WebHost.UseStaticWebAssets()`. It matters only when you run the build output, not the publish output, in an environment other than Development, as the [Getting Started](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/aspnet-core/llms-full.txt) example does.

### What the Tag Helper Loads

The [Tag Helper](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-aspnetcore/txsheetcontroltaghelper/llms-full.txt) writes the configuration of the editor into the page and adds two deferred scripts, once per page, also for several editors:

- `_content/TXTextControl.TXSheetControl.AspNetCore/tx-sheet-control.min.js`, the editor, with a `?v=` version for caching.
- `_content/TXTextControl.TXSheetControl.AspNetCore/tx-sheet-control-init.min.js`, which creates the editors of the page.

The editor then loads `fonts/catalog.json` and the fonts it needs from the same folder. The styles are part of the script and installed inside the editor's Shadow DOM, so the page needs no `<link>` element. Remove any manual `<script>` or `<link>` references to these files from older pages.

### Publish the Application

```bash
dotnet publish -c Release -o publish
```

Deploy the complete `publish` folder. It contains the package files in `wwwroot/_content/TXTextControl.TXSheetControl.AspNetCore/`: the scripts, `fonts/` with the catalog, the fonts and their notices, `languages/` and `licenses/`, each also as a precompressed `.br` and `.gz` copy. Run the application from that folder; it needs no Server package, no font service and no registration of services for the editor.

### Run Below a Path Base

When the application runs below a path, such as `https://example.com/reports/`, configure the path base before the static file middleware, for example with `app.UsePathBase("/reports")` or the settings of your reverse proxy. The Tag Helper then writes all URLs with the path, such as `/reports/_content/TXTextControl.TXSheetControl.AspNetCore/tx-sheet-control.min.js`, and the editor loads its fonts from there. A custom `FontCatalogURL` and your own scripts must include the path as well.

### Optional Font Routes

[MapTXSheetControlFonts](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-aspnetcore/txsheetcontrolfontendpoints/maptxsheetcontrolfonts-method/llms-full.txt) redirects the URLs `/sheet-fonts/…`, below the default catalog URL of the JavaScript editor, to the fonts of the package, such as `/sheet-fonts/catalog.json` to `/_content/TXTextControl.TXSheetControl.AspNetCore/fonts/catalog.json`. Pages with the Tag Helper do not need it. Use it when other scripts of your application create editors without setting `fontCatalogURL`.

### Use the Editor From Your Scripts

The editor exists only after the init script has run. Subscribe to the `txsheetcontrolready` and `txsheetcontrolerror` events, which bubble from the editor's element, before the scripts run, and use the `Spreadsheet` control in `event.detail`:

```html
<script>
document.addEventListener('txsheetcontrolready', event => {
    const editor = event.detail;
    editor.workbook.sheets.at(0).cell('A1').setText('Ready');
});
</script>
```

### Verify the Published Application

Open the published application in a browser and check:

- The editor appears and the browser console shows no errors.
- The requests for `tx-sheet-control.min.js`, `catalog.json` and the fonts return 200, below the path base if there is one.
- A formula calculates, and a PDF export contains the expected fonts and no watermark of the wrong license.
- A page with two editors works.

### Next Steps

- [Licensing](https://docs.textcontrol.com/tx-sheet-control/deployment/licensing/llms-full.txt): configure the license in `TXSheetControlOptions.License`.
- [Custom Fonts](https://docs.textcontrol.com/tx-sheet-control/deployment/custom-fonts/llms-full.txt): point the Tag Helper at a catalog of your own with `FontCatalogURL`.
- [Host Security and File Handling](https://docs.textcontrol.com/tx-sheet-control/deployment/security/llms-full.txt): align the Tag Helper's scripts with the content security policy of your application.

---

## Nearby

- **Previous:** [Custom Fonts](https://docs.textcontrol.com/tx-sheet-control/deployment/custom-fonts/llms-full.txt)
- **Next:** [Blazor Applications](https://docs.textcontrol.com/tx-sheet-control/deployment/blazor/llms-full.txt)
