Posty5.HtmlHosting 2.0.0

dotnet add package Posty5.HtmlHosting --version 2.0.0
                    
NuGet\Install-Package Posty5.HtmlHosting -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Posty5.HtmlHosting" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Posty5.HtmlHosting" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Posty5.HtmlHosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Posty5.HtmlHosting --version 2.0.0
                    
#r "nuget: Posty5.HtmlHosting, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Posty5.HtmlHosting@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Posty5.HtmlHosting&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Posty5.HtmlHosting&version=2.0.0
                    
Install as a Cake Tool

Posty5.HtmlHosting

Deploy and manage static HTML pages with the Posty5 .NET SDK. This package provides a complete C# client for creating, updating, and managing hosted HTML pages with features like GitHub integration, form submission tracking, monetization, and analytics.


🌟 What is Posty5?

Posty5 is a comprehensive suite of free online tools designed to enhance your digital marketing and social media presence. With over 4+ powerful tools and counting, Posty5 provides everything you need to:

  • πŸ”— Shorten URLs - Create memorable, trackable short links
  • πŸ“± Generate QR Codes - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
  • 🌐 Host HTML Pages - Deploy static HTML pages with dynamic variables and form submission handling
  • πŸ“’ Automate Social Media - Schedule and manage social media posts across multiple platforms
  • πŸ“Š Track Performance - Monitor and analyze your digital marketing efforts

Posty5 empowers businesses, marketers, and developers to streamline their online workflowsβ€”all from a unified control panel.

Learn more: https://posty5.com


πŸ“¦ About This Package

Posty5.HtmlHosting is a specialized tool package for deploying and managing static HTML pages through the Posty5 platform. It enables developers to quickly host landing pages, product pages, portfolios, and any static HTML content with professional features.

Key Capabilities

  • πŸ“ File Upload Hosting - Upload HTML files directly to high-performance cloud storage
  • πŸ™ GitHub Integration - Deploy HTML files directly from GitHub repositories
  • πŸ“Š Analytics & Tracking - Monitor page views, visitor locations, devices, and more
  • πŸ’° Monetization - Generate revenue through embedded advertisements
  • πŸ“ Form Submission Tracking - Capture and track form submissions automatically
  • πŸ”„ Dynamic Variables - Inject real-time data into your static pages
  • πŸ“± Google Sheets Integration - Auto-save form data to Google Sheets
  • πŸ” API Key Filtering - Scope resources by API key for multi-tenant applications
  • ⚑ High Performance - Fast global CDN delivery with caching
  • πŸ”’ Secure Hosting - HTTPS enabled with 24/7 security monitoring

Role in the Posty5 Ecosystem

This package works seamlessly with other Posty5 SDK packages:

  • Use Posty5.HtmlHostingVariables to manage dynamic variables
  • Use Posty5.HtmlHostingFormSubmission to handle form submissions
  • Use Posty5.ShortLink to create shortened URLs for your pages
  • Use Posty5.QRCode to generate QR codes linking to your pages

Perfect for developers, marketers, designers, and entrepreneurs who need fast, reliable HTML hosting with built-in tracking and monetization capabilities.


πŸ“₯ Installation

Install via NuGet Package Manager:

dotnet add package Posty5.HtmlHosting

Or via Package Manager Console:

Install-Package Posty5.HtmlHosting

πŸš€ Quick Start

Here's a minimal example to get you started:

using System.Text;
using Posty5.Core.Configuration;
using Posty5.Core.Http;
using Posty5.HtmlHosting;
using Posty5.HtmlHosting.Models;

// Initialize the HTTP client with your API key
var options = new Posty5Options
{
    ApiKey = "your-api-key" // Get from https://studio.posty5.com/account/settings?tab=APIKeys
};
var httpClient = new Posty5HttpClient(options);

// Create the HTML Hosting client
var htmlHosting = new HtmlHostingClient(httpClient);

// Create and deploy an HTML page
var htmlContent = @"
<!DOCTYPE html>
<html>
<head>
  <title>My Landing Page</title>
</head>
<body>
  <h1>Welcome to My Page!</h1>
  <p>This page is hosted on Posty5.</p>
</body>
</html>";

using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent));

var page = await htmlHosting.CreateWithFileAsync(
    new CreateHtmlPageFileRequest
    {
        Name = "My First Landing Page", // Page name for your dashboard
        FileName = "landing.html" // File name
    },
    fileStream
);

Console.WriteLine($"Page URL: {page.ShorterLink}");
Console.WriteLine($"Page ID: {page.Id}");

πŸ“š API Reference & Examples

Creating HTML Pages

CreateWithFileAsync

Upload an HTML file to create a hosted page.

Parameters:

  • data (CreateHtmlPageFileRequest): Configuration for the page
    • Name (string): Display name for the page in your dashboard
    • FileName (string): Name of the HTML file
    • CustomLandingId (string?, optional): Custom URL identifier
    • IsEnableMonetization (bool?, optional): Enable ad monetization
    • AutoSaveInGoogleSheet (bool?, optional): Auto-save form data to Google Sheets
    • Tag (string?, optional): Tag for categorization
    • RefId (string?, optional): Your custom reference ID
  • fileStream (Stream): The HTML file content stream
  • contentType (string, optional): Content type (default: "text/html")

Returns: Task<HtmlPageFileResponse>

  • Id (string): Unique page ID
  • ShorterLink (string): Public URL to access the page
  • FileUrl (string): Direct URL to the uploaded file

Example:

// Basic page creation
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent));

var page = await htmlHosting.CreateWithFileAsync(
    new CreateHtmlPageFileRequest
    {
        Name = "Simple Page",
        FileName = "index.html"
    },
    fileStream
);

Console.WriteLine($"Live URL: {page.ShorterLink}");
// Page with custom URL and monetization
var page = await htmlHosting.CreateWithFileAsync(
    new CreateHtmlPageFileRequest
    {
        Name = "Product Launch Page",
        FileName = "product.html",
        CustomLandingId = "product-2024", // Custom URL: posty5.com/product-2024
        IsEnableMonetization = true, // Enable ads for revenue
        Tag = "marketing",
        RefId = "campaign-spring-2024"
    },
    fileStream
);
// Page with form submission tracking
var page = await htmlHosting.CreateWithFileAsync(
    new CreateHtmlPageFileRequest
    {
        Name = "Contact Form",
        FileName = "contact.html",
        AutoSaveInGoogleSheet = true, // Auto-save form data to Google Sheets
        Tag = "forms"
    },
    fileStream
);

CreateWithGithubFileAsync

Deploy an HTML file directly from a GitHub repository.

Parameters:

  • data (CreateHtmlPageGithubRequest): Configuration for the page
    • Name (string): Display name for the page
    • GithubInfo (GithubInfo): GitHub file information
      • FileURL (string): Full GitHub file URL (e.g., https://github.com/user/repo/blob/main/index.html)
    • CustomLandingId (string?, optional): Custom URL identifier
    • IsEnableMonetization (bool?, optional): Enable monetization
    • AutoSaveInGoogleSheet (bool?, optional): Auto-save form data
    • Tag (string?, optional): Tag for categorization
    • RefId (string?, optional): Your custom reference ID

Returns: Task<HtmlPageGithubResponse>

  • Id (string): Unique page ID
  • ShorterLink (string): Public URL to access the page
  • GithubInfo (GithubInfo): GitHub file information

Example:

// Deploy from GitHub
var page = await htmlHosting.CreateWithGithubFileAsync(new CreateHtmlPageGithubRequest
{
    Name = "Portfolio Site",
    GithubInfo = new GithubInfo
    {
        FileURL = "https://github.com/username/portfolio/blob/main/index.html"
    }
});

Console.WriteLine($"Deployed URL: {page.ShorterLink}");
// GitHub deployment with all options
var page = await htmlHosting.CreateWithGithubFileAsync(new CreateHtmlPageGithubRequest
{
    Name = "Open Source Landing Page",
    GithubInfo = new GithubInfo
    {
        FileURL = "https://github.com/Netflix/netflix.github.com/blob/master/index.html"
    },
    CustomLandingId = "oss-project",
    IsEnableMonetization = false, // No ads on this page
    Tag = "open-source",
    RefId = "github-deploy-001"
});

Retrieving HTML Pages

GetAsync

Retrieve details of a specific HTML page by ID.

Parameters:

  • id (string): The unique page ID

Returns: Task<HtmlPageModel> - Complete page details

Example:

var page = await htmlHosting.GetAsync("page-id-123");

Console.WriteLine($"Page Name: {page.Name}");
Console.WriteLine($"URL: {page.ShorterLink}");
Console.WriteLine($"Created: {page.CreatedAt}");

if (page.SourceType == "github")
{
    Console.WriteLine($"GitHub URL: {page.GithubInfo?.FileURL}");
}

ListAsync

Search and filter HTML pages with pagination.

Parameters:

  • listParams (ListHtmlPagesParams, optional): Filter criteria
    • Name (string): Search by page name
    • SourceType (string): Filter by source type ('file' or 'github')
    • Tag (string): Filter by tag
    • RefId (string): Filter by reference ID
    • IsEnableMonetization (bool?): Filter by monetization status
    • AutoSaveInGoogleSheet (bool?): Filter by Google Sheets integration
    • IsTemp (bool?): Filter temporary pages
  • pagination (PaginationParams, optional): Pagination options
    • PageNumber (int): Page number (default: 1) -- Note: C# uses PageNumber vs TS 'page'
    • PageSize (int): Items per page (default: 10)

Returns: Task<PaginationResponse<HtmlPageModel>>

Example:

// Get all pages with pagination
var result = await htmlHosting.ListAsync(
    null,
    new PaginationParams { PageNumber = 1, PageSize = 20 }
);

Console.WriteLine($"Found {result.Pagination.TotalItems} pages");
foreach (var page in result.Data)
{
    Console.WriteLine($"- {page.Name}: {page.ShorterLink}");
}
// Search by name
var result = await htmlHosting.ListAsync(
    new ListHtmlPagesParams { Name = "landing" },
    new PaginationParams { PageNumber = 1, PageSize = 10 }
);
// Filter by multiple criteria
var filtered = await htmlHosting.ListAsync(new ListHtmlPagesParams
{
    SourceType = "file", // Only uploaded files
    IsEnableMonetization = true, // Only monetized pages
    Tag = "marketing" // Tagged as 'marketing'
});
// Get pages by your reference ID
var myPages = await htmlHosting.ListAsync(new ListHtmlPagesParams
{
    RefId = "campaign-2024-q1"
});

LookupAsync

Get a simplified list of pages (ID and name only). Useful for dropdowns and selection lists.

Returns: Task<List<HtmlPageLookupItem>> - List of objects with Id and Name.

Example:

var pages = await htmlHosting.LookupAsync();

// Use in a dropdown or list
foreach (var page in pages)
{
    Console.WriteLine($"ID: {page.Id}, Name: {page.Name}");
}

LookupFormsAsync

Get form IDs detected in an HTML page (useful for form submission tracking).

Parameters:

  • id (string): HTML page ID

Returns: Task<List<FormLookupItem>> - List of form information

Example:

var forms = await htmlHosting.LookupFormsAsync("page-id-123");

Console.WriteLine($"Found {forms.Count} forms on this page");
foreach (var form in forms)
{
    Console.WriteLine($"Form ID: {form.Id}, Name: {form.Name}");
}

Updating HTML Pages

UpdateWithFileAsync

Update an existing page with a new HTML file.

Parameters:

  • id (string): Page ID to update
  • data (UpdateHtmlPageFileRequest): Update configuration
    • Name (string?): New page name
    • FileName (string): New file name
    • CustomLandingId (string?): New custom URL
    • IsEnableMonetization (bool?): Toggle monetization
    • AutoSaveInGoogleSheet (bool?): Toggle Google Sheets
    • Tag (string?): New tag
    • RefId (string?): New reference ID
  • fileStream (Stream): New HTML file content stream

Returns: Task<HtmlPageFileResponse>

Example:

var updatedContent = "<html><body><h1>Content has been updated!</h1></body></html>";
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(updatedContent));

var updated = await htmlHosting.UpdateWithFileAsync(
    "page-id-123",
    new UpdateHtmlPageFileRequest
    {
        Name = "Updated Landing Page",
        FileName = "landing-v2.html"
    },
    fileStream
);

Console.WriteLine($"Updated URL: {updated.ShorterLink}");

UpdateWithGithubFileAsync

Update a page to use a different GitHub file or update GitHub settings.

Parameters:

  • id (string): Page ID to update
  • data (UpdateHtmlPageGithubRequest): Update configuration
    • Name (string?): New page name
    • GithubInfo (GithubInfo): New GitHub file information
    • ... other optional fields same as create

Returns: Task<HtmlPageGithubResponse>

Example:

var updated = await htmlHosting.UpdateWithGithubFileAsync(
    "page-id-123",
    new UpdateHtmlPageGithubRequest
    {
        Name = "Updated from GitHub",
        GithubInfo = new GithubInfo
        {
            FileURL = "https://github.com/username/repo/blob/main/updated.html"
        },
        IsEnableMonetization = false
    }
);

Page Operations

CleanCacheAsync

Clear the cache for a page to force fresh content delivery. Useful after updating content.

Parameters:

  • id (string): HTML page ID

Returns: Task

Example:

// Clear cache after updating external content
await htmlHosting.CleanCacheAsync("page-id-123");
Console.WriteLine("Cache cleared - fresh content will be served");

DeleteAsync

Permanently delete an HTML page.

Parameters:

  • id (string): HTML page ID to delete

Returns: Task

Example:

await htmlHosting.DeleteAsync("page-id-123");
Console.WriteLine("Page deleted successfully");

πŸ”’ Error Handling

All methods may throw exceptions from Posty5.Core.Exceptions. Handle them appropriately:

using Posty5.Core.Exceptions;

try
{
    var page = await htmlHosting.GetAsync("invalid-id");
}
catch (Posty5AuthenticationException ex)
{
    Console.WriteLine("Invalid API key");
}
catch (Posty5NotFoundException ex)
{
    Console.WriteLine("Page not found");
}
catch (Posty5ValidationException ex)
{
    Console.WriteLine($"Invalid data: {ex.Message}");
}
catch (Posty5RateLimitException ex)
{
    Console.WriteLine("Rate limit exceeded");
}
catch (Posty5Exception ex)
{
    Console.WriteLine($"Unexpected error: {ex.Message}");
}

πŸ“– Resources


πŸ“¦ Packages

This SDK ecosystem contains the following tool packages:

Package Description Version NuGet
Posty5.Core Core HTTP client and models 1.0.0 πŸ“¦ NuGet
Posty5.ShortLink URL shortener client 1.0.0 πŸ“¦ NuGet
Posty5.QRCode QR code generator client 1.0.0 πŸ“¦ NuGet
Posty5.HtmlHosting HTML hosting client 1.0.0 πŸ“¦ NuGet
Posty5.HtmlHostingVariables Variable management 1.0.0 πŸ“¦ NuGet
Posty5.HtmlHostingFormSubmission Form submission management 1.0.0 πŸ“¦ NuGet
Posty5.SocialPublisherWorkspace Social workspace management 1.0.0 πŸ“¦ NuGet
Posty5.SocialPublisherTask Social publishing task client 1.0.0 πŸ“¦ NuGet

πŸ†˜ Support

MIT License - see LICENSE file for details.


Made with ❀️ by the Posty5 team

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 92 2/1/2026
1.0.0 92 1/21/2026