Web Studio is here! An enhanced experience to make it easier to create, preview, and collaborate on your website contentLearn More
Building websites and web applications with .NET 7 and Agility CMS not only offers a beautiful and performant experience for your Users but also delivers an amazing experience for both Developers and Editors.
The Agility SDK was designed to be as flexiable, modular and simple. There are two main functions the SDK provides:
Therefore Agility SDK is broken into 2 packages:
Don't need page management? Then you can use the Agility Fetch API to only access your content.
Want to know how to include Agility .NET SDK packages in your site?
Thats it at a high level! Now lets get started...
First you'll need an account and access to an instance. When getting started with Agility CMS and .NET 7, we recommend using our Template to get you comfortable and to view an example based on best practices.
Create a Free Agility CMS Account
Once logged into Agility CMS, you'll want to grab your API credentials so your .NET 7 site can authenticate and retrieve data from your instance.
From your Agility CMS dashboard, click into Settings > API Keys.
Take note of these credentials and copy them somewhere temporarily as you'll need to use them later.
Agility provides an easy-to-use CLI tool that helps you download the Content Models from your Agility CMS instance, and generates the classes of the Content Models for you.
cd
into the Agility.NET.AgilityCLI
directory.App.config
file.
dotnet run update preview
.<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="InstanceGUID" value="" />
<add key="WebsiteName" value="" />
<add key="FetchAPIKey" value="" />
<add key="PreviewAPIKey" value="" />
<add key="Path" value="" />
</appSettings>
</configuration>
Get these values from the API Keys page in Agility Settings => https://manager.agilitycms.com/settings/apikeys
If using MacOS, you may need to use forward slashes ("/") in the value for your Path.
cd
into the Agility.NET.Starter
directory.appsettings.json
file.appsettings.json
file with the credentials you saved from before.{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"AppSettings": {
"InstanceGUID": "",
"SecurityKey": "",
"WebsiteName": "",
"FetchAPIKey": "",
"PreviewAPIKey": "",
"Locales": "en-us",
"ChannelName": "website",
"CacheInMinutes": 5
}
}
Get these values from the API Keys page in Agility Settings => https://manager.agilitycms.com/settings/apikeys
To start your site run the follwoing commands:
dotnet build
=> Builds your .NET project.
dotnet run
=> Builds & runs your .NET project.
Thats it! Happy coding :)