See Agility CMS in action. Watch a product demo
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 | Blazor | Modern apps, interactive UIs | Server-side + optional SignalR |
| MVC | 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
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:
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 guide for detailed setup instructions.
Documentation
Getting Started
- Getting Started - Set up your first Agility + .NET project
Starters
- Blazor SSR Starter - Modern Blazor with optional interactivity
- MVC Starter - Traditional Razor Pages approach
Core Concepts
- How Pages Work - Dynamic page routing and the sitemap
- How Components Work - Building reusable content modules
- How Page Models Work - Defining page layouts and zones
Development
- Fetching Content - REST API, GraphQL, and typed responses
- Configuration - Settings, environment variables, and caching
Deployment & Operations
- Deploy to Azure - One-click deployment and CI/CD setup
- Migration Guide - Upgrading from older .NET versions
Sample Code
Fetch a Content List
// Using the FetchApiService
var posts = await FetchApi.GetTypedContentList<Post>(
referenceName: "posts",
locale: "en-us",
take: 10
);
Render a Component (Blazor)
@* RichTextArea.razor *@
<div class="prose max-w-none">
@((MarkupString)(Fields?.TextBlob ?? ""))
</div>
@code {
[Parameter] public RichTextArea? Fields { get; set; }
}
Render a Component (MVC)
// ViewComponent
public class RichTextArea : ViewComponent
{
public IViewComponentResult Invoke(ModuleModel module)
{
var fields = module.Model.Fields.ToObject<RichTextAreaFields>();
return View(fields);
}
}
@* Views/PageModules/RichTextArea.cshtml *@
@model RichTextAreaFields
<div class="prose max-w-none">
@Html.Raw(Model?.TextBlob)
</div>
Resources
Get Help
In this Article:
Was this article helpful?