# Agility and .NET

> Source: https://agilitycms.com/docs/dotNet/agility-and-net

Build fast, SEO-optimized websites using .NET and Agility CMS. Whether you're creating a marketing site, blog, or enterprise application, this guide will help you leverage the power of .NET with Agility's headless CMS.

## Why .NET with Agility CMS?

**.NET** is Microsoft's powerful, cross-platform framework for building modern web applications. Combined with **Agility CMS**, you get:

- **Server-Side Rendering (SSR)** for SEO-friendly, fast-loading pages
- **Editor-Driven Pages** where content editors control the sitemap without developer intervention
- **Flexible Content Modeling** with strongly-typed C# classes
- **Enterprise-Ready** architecture with built-in caching and performance optimization
- **Azure-Native** deployment with one-click setup

## Choose Your Starter

We provide two production-ready starters for building websites with Agility CMS and .NET:

| Starter | Framework | Best For | Interactivity |
|---------|-----------|----------|---------------|
| [**Blazor SSR**](/docs/dotNet/blazor-starter) | Blazor | Modern apps, interactive UIs | Server-side + optional SignalR |
| [**MVC**](/docs/dotNet/mvc-starter) | Razor Pages | Traditional web apps | Server-side only |

Both starters include:
- Dynamic page routing based on Agility sitemap
- Component-based architecture
- Preview mode support
- Tailwind CSS styling
- One-click Azure deployment

## The Agility SDK

The Agility .NET SDK consists of a NuGet package for accessing content:

### Agility.NET.FetchAPI

```bash
dotnet add package Agility.NET.FetchAPI
```

**Capabilities:**
- Fetch pages and sitemaps
- Retrieve content items and lists
- Query content via GraphQL
- Handle preview mode
- Typed responses with generics

## Quick Start

Clone the starter repository and choose your preferred framework:

```bash
git clone https://github.com/agility/agilitycms-dotnet-starter.git
cd agilitycms-dotnet-starter

# For Blazor SSR
cd Agility.NET.Blazor.Starter

# Or for MVC/Razor Pages
cd Agility.NET.MVC.Starter

# Configure your credentials in appsettings.local.json
# Then run
dotnet watch
```

See the [Getting Started](/docs/dotNet/getting-started) guide for detailed setup instructions.

## Documentation

### Getting Started
- [Getting Started](/docs/dotNet/getting-started) - Set up your first Agility + .NET project

### Starters
- [Blazor SSR Starter](/docs/dotNet/blazor-starter) - Modern Blazor with optional interactivity
- [MVC Starter](/docs/dotNet/mvc-starter) - Traditional Razor Pages approach

### Core Concepts
- [How Pages Work](/docs/dotNet/how-pages-work) - Dynamic page routing and the sitemap
- [How Components Work](/docs/dotNet/how-components-work) - Building reusable content modules
- [How Page Models Work](/docs/dotNet/how-page-models-work) - Defining page layouts and zones

### Development
- [Fetching Content](/docs/dotNet/fetching-content) - REST API, GraphQL, and typed responses
- [Configuration](/docs/dotNet/configuration) - Settings, environment variables, and caching

### Deployment & Operations
- [Deploy to Azure](/docs/dotNet/deploy-to-azure) - One-click deployment and CI/CD setup
- [Migration Guide](/docs/dotNet/migration-guide) - Upgrading from older .NET versions

## Sample Code

### Fetch a Content List

```csharp
// Using the FetchApiService
var posts = await FetchApi.GetTypedContentList<Post>(
    referenceName: "posts",
    locale: "en-us",
    take: 10
);
```

### Render a Component (Blazor)

```razor
@* RichTextArea.razor *@
<div class="prose max-w-none">
    @((MarkupString)(Fields?.TextBlob ?? ""))
</div>

@code {
    [Parameter] public RichTextArea? Fields { get; set; }
}
```

### Render a Component (MVC)

```csharp
// ViewComponent
public class RichTextArea : ViewComponent
{
    public IViewComponentResult Invoke(ModuleModel module)
    {
        var fields = module.Model.Fields.ToObject<RichTextAreaFields>();
        return View(fields);
    }
}
```

```razor
@* Views/PageModules/RichTextArea.cshtml *@
@model RichTextAreaFields

<div class="prose max-w-none">
    @Html.Raw(Model?.TextBlob)
</div>
```

## Resources

- [GitHub Repository](https://github.com/agility/agilitycms-dotnet-starter)
- [Agility CMS Documentation](https://agilitycms.com/docs)
- [NuGet: Agility.NET.FetchAPI](https://www.nuget.org/packages/Agility.NET.FetchAPI)

## Get Help

- [Agility CMS Community](https://agilitycms.com/community)
- [GitHub Issues](https://github.com/agility/agilitycms-dotnet-starter/issues)
- [Contact Support](https://agilitycms.com/support)
