net3000.content.client
1.0.1
dotnet add package net3000.content.client --version 1.0.1
NuGet\Install-Package net3000.content.client -Version 1.0.1
<PackageReference Include="net3000.content.client" Version="1.0.1" />
<PackageVersion Include="net3000.content.client" Version="1.0.1" />
<PackageReference Include="net3000.content.client" />
paket add net3000.content.client --version 1.0.1
#r "nuget: net3000.content.client, 1.0.1"
#:package net3000.content.client@1.0.1
#addin nuget:?package=net3000.content.client&version=1.0.1
#tool nuget:?package=net3000.content.client&version=1.0.1
net3000.content.client
Overview
The net3000.content.client package is the typed client for the Content Management (cm) routes on
api.net3000.ca. A client website reads CMS pages, categories, menus, banners, videos, forms and
testimonials through ordinary C# methods — with no database connection string — instead of composing
the route, the parameter names and the response shape by hand:
// before: the url, the parameter names and the model are the caller's problem
var page = connector.getRequest<cm_content>($"cm/content?code={code}&serverbind=true");
// after
var page = cm.GetContent(code: code, serverbind: true);
The methods are one per live /cm/ route — forty of them, listed in CmRoutes.All — and they return
the models the api already serialises (apiResponse<cm_content>, apiResponse<cm_categories>, …). The
package wraps the api; it is not a second implementation of the CMS. The content library next door
(Net3000.Content) still owns the business logic and still needs a DbContext; nothing here calls it.
This is the first of the per-application client packages (epic
#8079, issue
#8080); decisions D1–D10 are in
Documentation/Brainstorms/2026-11-28-application-libraries-as-api-clients.md.
Capabilities
- Pages —
GetContent,GetContentHomepage,GetPages,GetPagesMonth,GetPagesTag,GetSearchPages,GetArchivelinksMonths,GetScheduledcontent,GetAmpcontent,GetAmp,GetSitemap. - Categories —
GetCategory/GetSection(the same api action under both live names),GetCategoryItems,GetPagesCategory,GetPagesCategoryV2. - Menus —
GetMenu. - Banners —
GetBanner,GetBannerCategory,GetBannerCategoryV2, andGetBannerClick, which returns the click-through url for anhrefrather than calling it. - Videos —
GetVideos,GetVideosDetails,GetVideoCategory,GetVideosPlayback(a short-lived signed player url for a privately hosted video),GetYoutubeChannelSafe. - Forms —
GetForm,PostProcessform,PostProcessformbyfile(multipart, with attachments),GetFormsFiles(download an attachment). - Testimonials —
GetTestimonials,PostTestimonials,GetTestimonialsReview,PostTestimonialsReview. - Shared-shell projections —
GetContentSafe,GetCategorySafe,GetMenuSafe,GetBannerSafe,GetFormSafe,GetTestimonialsSafe: display-only shapes that never carry stored scripts, Vue templates, header code or identity. Prefer these on a shared-origin shell. - Contract checking — a wrapped route that answers 404 or 405 throws
CmApiContractExceptionnamingCmClient.CmContractVersion, instead of reading as an empty result.
Usage Example
using net3000.content.client;
public class HomeController : Controller
{
private readonly IConfiguration configuration;
public HomeController(IConfiguration configuration)
{
this.configuration = configuration;
}
// Built per action, not in the constructor: HttpContext is null while the constructor runs, so a
// client built there has no request to resolve the tenant from and reads the host's default account.
// CmClient.For wires its apiConnector in the order that connector requires -- configuration first
// (so a site that pins its tenant keeps it), then the request context.
private CmClient Cm => CmClient.For(configuration, HttpContext);
public IActionResult Index()
{
var cm = Cm;
var page = cm.GetContentHomepage(serverbind: true);
if (!page.success)
{
return View("message", page);
}
ViewData["title"] = page.data.title;
ViewData["menu"] = cm.GetMenu("main").data;
ViewData["banner"] = cm.GetBanner(code: "home-hero").data;
return View(page);
}
}
Where a controller already owns an apiConnector, wrap that one so both go to the api as the same
tenant:
var cm = new CmClient(connector);
Submitting a form with attachments needs the transport's upload part. Alias it — commonCore declares a
net3000.postFile too, so the bare name is ambiguous inside a net3000.* namespace:
using ApiPostFile = net3000.apiConnectorCore.models.postFile;
var values = JsonSerializer.SerializeToUtf8Bytes(new Dictionary<string, string>
{
["name"] = form["name"], ["email"] = form["email"]
});
var result = cm.PostProcessformbyfile(
files:
[
// The api reads the field values out of the part whose content type contains "json".
new ApiPostFile { fileName = "values.json", byteArray = values, contentType = "application/json" },
new ApiPostFile { fileName = upload.FileName, fileStream = upload.OpenReadStream() }
],
code: "contact-us");
if (result.success) { /* result.data is the submission id */ }
Usage Notes
- The transport is
apiConnectorCore(1.0.13 or newer). Tenant selection (account/accountToken), the trusted-origin header, the outage page andapiResponsedeserialisation live there and are shared with every other call the site makes.CmClient.Connectorexposes it forApiUnavailable,LastHttpStatusCode,ServiceUnavailablePage()andTryRenderSuspensionPage(). - The calls are synchronous, because the connector is. A site converting from
connector.getRequest<T>(...)changes the call, not the shape of its controller. - Method names are derived from the route, not chosen: the HTTP method in title case, then each path
segment after
cmwith its first letter upper-cased and the rest exactly as the api spells it, with{…}segments dropped.GET /cm/bannerCategory/v2isGetBannerCategoryV2;GET /cm/videos/{id:int}/playbackisGetVideosPlayback.Tasks/assert-cm-client-routes.cjsenforces it, so a renamed route cannot keep its old method name. - An omitted argument is not sent. Every optional parameter is nullable and left out of the query string when null, so the api applies its own default rather than binding an empty value over it.
CmContractVersionis the api surface this release was built against (D9). A wrapped JSON route that answers from a different url than the one asked for, or answers 404 or 405, throwsCmApiContractException; a site pinned to an old package fails loudly instead of rendering empty pages. The redirect check is the one that matters: the api does not 404 an unknown route — it sends it to/message/404, which answers HTTP 200 and asuccess = true"Page Not Found" envelope whosedatais alert HTML. A typed read of that fails deserialisation and arrives as a plainsuccess = false, which is indistinguishable from an account with no content. The five non-JSON routes report their status onCmRawResponseinstead, because a 404 there is a real answer — but they report the redirect too, onCmRawResponse.Redirected, and.Successrequires a 2xx and no redirect.GET /cm/ampreturns a bodyless 4xx for a page that is unpublished, withheld or not this tenant's, so without that a caller is handed a "successful" AMP document that is really the api's error page. Read.Success, never.StatusCodeon its own.- Versioned route spellings (
/v1.0/cm/…) are not wrapped. They are the api's compatibility surface for callers pinned to an older response shape; a versioned package does not need them. - Five routes still answer an untyped shape.
GetVideos,GetVideosDetailsandGetVideosPlaybackreturnapiResponse<dynamic>,GetFormreturnsapiResponse<object>andGetPagesCategoryV2returnsapiResponse<List<object>>— because the api builds those responses anonymously and declares them that way. Typing them means adding a DTO on the api side, not a copy in this package (D6).GetVideosandGetVideosDetailsdata is aCmVideoApiRow; read it as one. - Account isolation stays server-side. The tenant comes from the request, never from an argument.
There is deliberately no
accountparameter on any method, andformOptions.accountshould be left unset — the api ignores a client-supplied id.
Public API
<details> <summary>net3000.content.client.CmClient</summary>
| Member | Summary | Parameters |
|---|---|---|
const string CmContractVersion |
The cm route contract this release was built against (D9). |
— |
static string PackageVersion |
This package's version, as reported in CmApiContractException. |
— |
CmClient(apiConnector connector) |
Wraps a connector the caller already owns and wired. | connector (apiConnector) |
static CmClient For(IConfiguration configuration, HttpContext context = null) |
Builds a client with its own connector, configuration before context. | configuration (IConfiguration), context (HttpContext) |
apiConnector Connector |
The transport underneath, for outage and suspension handling. | — |
apiResponse<cm_content> GetContent(int? id, string code, bool? excludetitle, bool? serverbind) |
GET /cm/content — one page by id or friendly code. |
id (int?), code (string), excludetitle (bool?), serverbind (bool?) |
apiResponse<cm_content> GetContentHomepage(bool? excludetitle, bool? serverbind) |
GET /cm/content/homepage. |
excludetitle (bool?), serverbind (bool?) |
apiResponse<CmSharedShellPage> GetContentSafe(int? id, string code) |
GET /cm/content/safe — display-only page projection. |
id (int?), code (string) |
apiResponse<cm_content> GetAmpcontent(int? id, string code) |
GET /cm/ampcontent. |
id (int?), code (string) |
CmRawResponse GetAmp(int pageID) |
GET /cm/amp — the rendered AMP document, as HTML. |
pageID (int) |
apiResponse<List<cm_content>> GetPages(int? pageSize, int? pageIndex) |
GET /cm/pages. |
pageSize (int?), pageIndex (int?) |
apiResponse<List<cm_content>> GetPagesMonth(DateTime month, string categoryid) |
GET /cm/pages/month — one month of pages. |
month (DateTime), categoryid (string) |
apiResponse<List<cm_content>> GetPagesTag(string tag, int? pageSize, int? pageIndex) |
GET /cm/pages/tag. |
tag (string), pageSize (int?), pageIndex (int?) |
apiResponse<List<cm_content>> GetSearchPages(string search, string categoryid) |
GET /cm/searchPages. |
search (string), categoryid (string) |
apiResponse<Dictionary<string, string>> GetArchivelinksMonths() |
GET /cm/archivelinks/months. |
None |
apiResponse<List<cm_scheduledContent>> GetScheduledcontent(int locationId) |
GET /cm/scheduledcontent. |
locationId (int) |
CmRawResponse GetSitemap(int? id) |
GET /cm/sitemap — sitemap XML. |
id (int?) |
apiResponse<cm_categories> GetCategory(int? id, string code, bool? includePages, bool? includePageList, bool? includeSubSections, bool? includeSubSectionPages, bool? includeBanners, int? pageSize, int? pageIndex, string tag) |
GET /cm/category. |
see signature |
apiResponse<cm_categories> GetSection(…) |
GET /cm/section — the same action under the older route name. |
as GetCategory |
apiResponse<CmSharedShellCategory> GetCategorySafe(int? id, string code, int? pageIndex) |
GET /cm/category/safe. |
id (int?), code (string), pageIndex (int?) |
apiResponse<cm_categories> GetCategoryItems(int? id, string code) |
GET /cm/categoryItems. |
id (int?), code (string) |
apiResponse<List<cm_content>> GetPagesCategory(int id, bool? fullPage, int? pageSize, int? pageIndex) |
GET /cm/pages/category/{id}. |
id (int), fullPage (bool?), pageSize (int?), pageIndex (int?) |
apiResponse<List<object>> GetPagesCategoryV2(int id, int? pageSize, int? pageIndex, int? summarysize) |
GET /cm/pages/category/v2 — summary projection. |
id (int), pageSize (int?), pageIndex (int?), summarysize (int?) |
apiResponse<cm_menus> GetMenu(string code) |
GET /cm/menu. |
code (string) |
apiResponse<CmSharedShellMenu> GetMenuSafe(string code) |
GET /cm/menu/safe. |
code (string) |
apiResponse<PublicBannerResponse> GetBanner(int? id, string code, string zone, string appCode) |
GET /cm/banner — a banner and its in-flight slides. |
id (int?), code (string), zone (string), appCode (string) |
apiResponse<CmSharedShellBanner> GetBannerSafe(int? id, string code, string zone, string appCode) |
GET /cm/banner/safe. |
as GetBanner |
string GetBannerClick(int id) |
GET /cm/banner/click/{id} — returns the tracked url for an href; makes no call. |
id (int) |
apiResponse<cm_categories> GetBannerCategory(int? id, string code) |
GET /cm/bannerCategory. |
id (int?), code (string) |
apiResponse<cm_categories> GetBannerCategoryV2(int? id, string code) |
GET /cm/bannerCategory/v2. |
id (int?), code (string) |
apiResponse<List<CmVideoApiRow>> GetVideoCategory(int id) |
GET /cm/videoCategory/{id}. |
id (int) |
apiResponse<dynamic> GetVideos(int? size, int? page, string sortBy, string sortDirection) |
GET /cm/videos; data is a CmVideoApiRow list. |
size (int?), page (int?), sortBy (string), sortDirection (string) |
apiResponse<dynamic> GetVideosDetails(int id) |
GET /cm/videos/details; data is a CmVideoApiRow. |
id (int) |
apiResponse<dynamic> GetVideosPlayback(int id) |
GET /cm/videos/{id}/playback — signed player url, four-hour life. |
id (int) |
apiResponse<SharedShellChannel> GetYoutubeChannelSafe() |
GET /cm/youtube/channel/safe. |
None |
apiResponse<object> GetForm(string code, int? id) |
GET /cm/form — form definition and prepared template. |
code (string), id (int?) |
apiResponse<CmSharedShellForm> GetFormSafe(int? id, string code) |
GET /cm/form/safe. |
id (int?), code (string) |
CmRawResponse GetFormsFiles(int submissionId, Guid fileId) |
GET /cm/forms/files/{submissionId}/{fileId} — attachment bytes. |
submissionId (int), fileId (Guid) |
apiResponse<int> PostProcessform(formOptions formOptions) |
POST /cm/processform; data is the submission id. |
formOptions (formOptions) |
apiResponse<int> PostProcessformbyfile(IEnumerable<postFile> files, string code, int? id, IDictionary<string, string> fields) |
POST /cm/processformbyfile — multipart submit with attachments. |
files (IEnumerable<postFile>), code (string), id (int?), fields (IDictionary<string, string>) |
apiResponse<testimonialPage> GetTestimonials(int? pageSize, int? pageIndex, string stars) |
GET /cm/testimonials. |
pageSize (int?), pageIndex (int?), stars (string) |
apiResponse<testimonialPage> PostTestimonials(testimonialOptions myOptions) |
POST /cm/testimonials — the same read with options in the body. |
myOptions (testimonialOptions) |
apiResponse<CmSharedShellTestimonials> GetTestimonialsSafe(int? pageIndex) |
GET /cm/testimonials/safe. |
pageIndex (int?) |
CmRawResponse GetTestimonialsReview(string token) |
GET /cm/testimonials/review/{token} — the reviewer's page. |
token (string) |
apiResponse PostTestimonialsReview(string token, string status) |
POST /cm/testimonials/review/{token} — record the decision. |
token (string), status (string) |
</details>
<details> <summary>net3000.content.client — supporting types</summary>
| Member | Summary | Parameters |
|---|---|---|
CmRoute(string Method, string Template, string ClientMethod) |
One live /cm/ route and the method that wraps it. |
Method, Template, ClientMethod (string) |
static string CmRoute.ExpectedMethodName(string method, string template) |
The method name a route template must produce. | method (string), template (string) |
static IReadOnlyList<CmRoute> CmRoutes.All |
The whole wrapped surface — forty routes. | — |
CmRawResponse.StatusCode / .Body / .Bytes / .ContentType / .AnsweredBy / .Redirected / .Success |
What a non-JSON route returned. .Success is a 2xx from the path that was asked for; .Redirected is true when the api answered from somewhere else. |
— |
CmApiContractException.Method / .Url / .StatusCode / .ContractVersion / .PackageVersion |
Thrown when the api does not serve a wrapped route. | — |
</details>
License
This library is proprietary to Net3000. Redistribution or use outside Net3000.ca solutions is not permitted.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- apiConnectorCore (>= 1.0.14)
- Net3000.Content (>= 1.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 0 | 11/28/2026 |
1.0.1: Review follow-ups (#8109). CmRawResponse.Success now requires a 2xx AND that the api answered from the path that was asked for, and reports AnsweredBy / Redirected: the api redirects a bodyless 4xx to /message/404, which answers 200, so GetAmp reported success for a page that is unpublished, withheld or not this tenant's and handed back the error page as an AMP document. The contract guard compares the path only, not scheme and host, so an http-to-https upgrade, an apex-vs-www difference or a CDN hostname no longer makes every cm call throw CmApiContractException. Doc fixes: PostTestimonialsReview's status takes Approved or Rejected (not approved/declined), the README and <example> build the client per action rather than in a controller constructor where HttpContext is null, and GetBanner / GetBannerCategory / GetBannerCategoryV2 say that they record a billable ad impression per slide. 1.0.0: First release (#8080, epic #8079). One typed method per live /cm/ route on api.net3000.ca (40 routes), returning the models the api already serialises. Transport is apiConnectorCore 1.0.13, so tenant selection, the trusted-origin header, outage detection and apiResponse deserialisation stay in one place. A 404/405 on a wrapped JSON route throws CmApiContractException naming the cm contract version the package was built against, rather than reading as an empty result. Tasks/assert-cm-client-routes.cjs fails the build when a /cm/ route has no client method or a client method has no live route.