Skip to content
GeorgDanglPublic

About

Small Asp.Net Core app to host static html content with user management

Resources

Stars

5 stars

Watchers

2 watching

Forks

Repository files navigation

Dangl.WebDocumentation - Readme

Build Status

This is a small web application to host generated project documentation in static html format. It allows to control access to a project, either by making projects publicly available or by enabling access to projects for specific users.
It does accept a zip file as input and will then make the content available to be browsable through the web. You can use, for example, Sharpdox to create html documentation for C# projects, zip the output and upload it as project.

Tests and code coverage reports are generated by running TestaAndCoverage.ps1 in the root directory.

Setup

Configuration expects a connection string in the appsettings at Data:DanglDocuSqlConnection:ConnectionString and two variables, AllowUserRegistration and SiteTitle. Upon deployment, the first user to register is granted the admin role. For other users, admin roles are assigned manually by an existing admin.

Configuration

Admins create and manage projects, set which users can access them and upload packages via the web interface.

Upload a package

Projects are expected in zip format. The zip archives content is copied on the server under the App_Data folder. Projects have a property defining which relative path to use initially, e.g. index.html.

Via the web interface

Admins can simply select Upload Package in the admin section for a project and upload a zip file.

Via the API

In the project edit section, the API key for a project is set, it is used for http uploads. Example with cURL:
curl -F "ApiKey=<YourApiKey>" -F "Version=<DocVersion>" -F "ProjectPackage=@\"<PathToZipPackage>\"" https://<YourDomain>/API/Projects/Upload

You can optionally supply the string parameter markdownChangelog to include a changelog for the release.

Asset File Upload

Similarily, you can use the web interface or the API to upload asset files. Asset files are simply downloads that can be attached to a specific project and version.

curl -F "ApiKey=<YourApiKey>" -F "Version=<DocVersion>" -F "AssetFile=@\"<PathToZipPackage>\"" https://<YourDomain>/API/ProjectAssets/Upload

Access a package

Project names are required to be unique for pretty urls. Access is routed via https://<YourDomain>/Projects/<ProjectName>/<Version>/<PathToIndex>

The <Version> parameter may be set to latest to display the most recent version of the package.

Logged-in users can download the original zip package from the versions page for projects they can access; admins can download any package. Anonymous users cannot download packages, including those for public projects. Azure downloads use SAS links valid for five minutes, while disk storage serves the file directly. Both use the filename {ProjectName}_{Version}.zip.

When a version has a Markdown package, the versions page also offers Download Markdown Docs Package under the same access rules. This downloads the original Markdown ZIP as {ProjectName}_{Version}_markdown.zip, using the same Azure or disk download behavior.

The versions page also displays stored package sizes to admins. Sizes are queried from Azure Blob properties or disk metadata after upload and saved in the database; viewing the page does not query storage. Existing versions are populated by a Hangfire job in batches of 100. Packages whose metadata cannot be read are logged and left without a size for a later run, without blocking subsequent batches.

Admin storage reporting

The Admin project list shows HTML package, Markdown ZIP and asset sizes, plus the total across all versions of each project. These are database-backed logical file sizes, not storage-account billing figures; database storage, blob versions/snapshots and unreferenced files are not included. Asset sizes use the recorded upload size (the declared size for direct SAS uploads). Markdown sizes are saved on upload; the existing startup backfill job also populates sizes for older Markdown packages. Until backfill completes, or if metadata cannot be read, affected totals are labeled At least with the number of unavailable package sizes. The schema migration adds a nullable Markdown package size column and runs through the normal application migration process.

The read-only Hangfire recurring job MonthlyStorageAudit scans the projects and project-assets containers on the first day of each month at 00:00 UTC. It supports both Azure Blob and disk storage, compares stored paths against HTML, Markdown and asset references in SQL, and never scans unrelated containers such as data-protection keys. Files modified within the last 24 hours are skipped to avoid flagging uploads before their database transaction commits. Disk references are normalized to full filesystem paths before comparison; Azure blob names are compared exactly.

Open the Hangfire dashboard from Admin to trigger an audit manually or inspect a completed job's result, which includes unreferenced paths, sizes, a byte total and scan time. Findings are also logged as warnings. Storage/database errors fail the job rather than reporting a successful partial scan. No files are automatically deleted: findings are candidates for manual investigation, and references should be rechecked before removing anything.

MCP access for AI agents

The app includes an optional, read-only MCP server at https://<YourDomain>/mcp, using Streamable HTTP. It exposes list_projects, list_versions, list_documents, search_docs, and get_document. Every MCP request requires an OAuth access token, including requests for public projects. Normal public HTML browsing is unchanged. Project listings and all documentation operations enforce the user's existing project assignments and docu_project_access claims. The MCP tools never expose upload keys or upload/admin operations.

When MCP is enabled, signed-in users see a banner linking to the configurations on Manage Account. Hide once dismisses it for the browser session; Hide forever stores a browser-wide preference cookie for 400 days (subject to browser cookie policies). Clearing cookies restores the banner. Dismissal does not require JavaScript.

Upload Markdown documentation

Upload the normal HTML documentation package first, then a separate Markdown ZIP for the same explicit version. The admin package-upload page accepts these ZIPs, or a build pipeline can use the existing project upload key:

curl -F "ApiKey=<YourProjectUploadKey>" \
     -F "Version=1.2.3" \
     -F "MarkdownPackage=@docs-markdown.zip" \
     https://<YourDomain>/API/MarkdownDocuments/Upload

Successful uploads return {"documentCount":42}. Reuploading replaces that version's entire Markdown corpus atomically; it does not modify the HTML ZIP or other versions. Concurrent version changes reject the upload with an error; retry the request. Deleting a documentation version also deletes its Markdown documents.

Packages must contain UTF-8 .md or .markdown files. Relative directory paths, headings, Markdown and code examples are preserved; non-Markdown files, such as images, are ignored. Limits are 100 MiB compressed, 200 MiB of Markdown after decompression, 10 MiB per document, 10000 documents, and 20000 ZIP entries (including directories and non-Markdown files). Document paths must be unique ignoring case, at most 300 characters, and must not contain absolute paths or . / .. segments.

The Markdown ZIP is stored in shared file storage, while SQL holds only document paths and titles. Document reads extract content from the ZIP on demand; searches load its contents when requested and match case-insensitive keywords within the selected project/version. Every keyword must match. No external AI service, embeddings, or vector database is used. HTML-only versions remain browsable but return an explicit "no Markdown package" error to MCP clients.

Tools return resolved versions and source URLs at /MarkdownDocuments/{project}/{version}/{path}. These URLs serve the Markdown under the website's normal project-access checks. Lists have offset, limit, and nextOffset; document reads have offset, maxCharacters, totalCharacters, and nextOffset. Offsets in document reads count UTF-16 characters. Follow nextOffset until it is null to retrieve complete content. latest means the newest hosted version, including prereleases, just as on the website. MCP never silently substitutes another version or falls back to older Markdown; use list_versions and pin a version when developing against a particular release.

Configure OAuth

MCP is disabled by default. Before enabling it, configure Dangl.Identity to issue JWT access tokens for a dedicated MCP audience/resource, with a read scope such as docs:read. Tokens must have a GUID sub corresponding to the existing Dangl.Identity user ID, a scope claim containing the read scope, and an RFC 9068 access-token type (at+jwt or application/at+jwt). ID tokens, browser cookies, and project upload keys are not accepted by the MCP endpoint. Opaque access tokens are not supported.

For example:

{
  "BaseUrl": "https://docs.dangl-it.com",
  "DanglIdentityBaseUrl": "https://identity.example.com",
  "Mcp": {
    "Enabled": true,
    "Audience": "https://docs.dangl-it.com/mcp",
    "RequiredScope": "docs:read",
    "AllowedOrigins": []
  }
}

BaseUrl must be the public HTTPS origin without a path. Audience must exactly match the dedicated audience in issued tokens; clients use the public MCP URL as the OAuth resource parameter. The signing keys and issuer metadata are obtained from Dangl.Identity's HTTPS OIDC discovery endpoint. The app publishes anonymous OAuth Protected Resource Metadata at /.well-known/oauth-protected-resource/mcp, and returns 401 / 403 bearer challenges instead of browser-login redirects. Enabling MCP does not change the website's cookie/OIDC authentication defaults.

Register each supported agent as its own OAuth client in Dangl.Identity, using authorization code with PKCE S256. Configure its callback URLs and grant the read scope and MCP resource. Do not distribute this website's existing OAuth client secret to agents. Pre-registered client IDs work; Client ID Metadata Documents can simplify onboarding if the identity provider supports them. For long-running interactive use, configure refresh-token issuance/rotation on the identity provider and client.

Bearer tokens need either the appropriate docu_project_access claims or existing database project assignments. Identity-provider-derived assignments retain the app's existing hourly synchronization behavior. Token-carried access claims remain valid until token expiry, so use short-lived access tokens when prompt revocation matters.

Native/CLI clients normally send no Origin header. Browser clients must have their exact HTTPS origin listed in AllowedOrigins; the MCP endpoints enable CORS only for those origins. Responses are not publicly cacheable. MCP requests are limited to 120 per minute per user per application instance.

For VS Code, a minimal .vscode/mcp.json configuration is:

{
  "servers": {
    "DanglDocu": {
      "type": "http",
      "url": "https://docs.dangl-it.com/mcp",
      "oauth": {
        "clientId": "<AgentClientIdRegisteredInDangl.Identity>"
      }
    }
  }
}

The client completes browser sign-in and sends Authorization: Bearer <access-token> on MCP requests. The server supports the current per-request MCP protocol and older initialization-based Streamable HTTP clients through the SDK. The schema migration adds the Markdown document table and an upload-concurrency revision on project versions; apply it through the app's normal database migration/deployment process before enabling MCP.

Conventions When Accessing Documentation

Project file urls have the following format:

https://<YourDomain>/Projects/<ProjectName>/<Version>/<PathToFile>
  • If PathToFile is missing, a redirect is returned pointing to the entry point, e.g. https://docs.dangl-it.com/Projects/LightQuery/1.1.0 redirects to https://docs.dangl-it.com/Projects/LightQuery/1.1.0/index.html
  • If the Version is not found but a higher version is present, it redirects to the newer version. This is useful when you want to delete documentations for prerelease versions. For example, 1.0.0-beta1 is requested but not present, if 1.0.0 is present, it gets redirected to it. This keeps old urls from becoming unavailable
  • If PathToFile is pointing to a non-existing file, a redirect to the entry point is returned
  • Project assets can either be access via /ProjectAssets/{projectName}/{version} or /ProjectAssets/{projectName}/latest

Response Caching

Responses for project files have two different Cache-Control headers:

  • 3600 (1 hour) if the version accessed is latest
  • 604800 (7 days) if any other version is accessed

License

View

About

Small Asp.Net Core app to host static html content with user management

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages