C#, Razor & Dynamic Code
When you implement solutions using 2sxc, most of your server-side code will be written in C#.
C# Files in 2sxc Apps
You will create many dynamic
.cshtml files in the App folder:
- Razor components, shared Razor and Razor Code-Behind (
- WebApi Controllers (
*Controller.csfiles in the
- Shared code (
*.csfiles in any folder)
These files are in your App folder as Dynamic Code and have three core features:
- The source code can be changed at any time
- Changes are immediately live without restarting the CMS
- Cool APIs 😎 help you work with dynamic data (Entities)
person in the following Razor template is a Dynamic Entity - meaning that it can have different properties depending on the configuration. In this case it seems to have
<div @Edit.Toolbar(person)> @person.FirstName @person.LastName - @Text.First(person.Gender, "unknown") </div>
The code first creates a
div tag which would show a hover-toolbar (to admins only) for editing the
person. It then shows the names and the gender - which if not determined will show as
This kind of code is easy understand for people who know HTML. It's also very easy to customize if you need a different output - since it's basically HTML and placeholders.
This documentation contains the following sections
- Dynamic Data Everything you need to understand how data, especially dynamic data, works in 2sxc.
- Dynamic Code
The shared API on all Dynamic Code - Razor, WebApi or other.
The APIs special to Razor templates
- Web API
Everything you need to know to create/customize Web API Controllers
- External API
Guides you to access 2sxc-instances on the server from the Theme, WebForms or other MVC components
Important APIs when Working with Content-Items/Data
TODO: this must be moved elsewhere