> For the complete documentation index, see [llms.txt](https://docs.zongsoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zongsoft.com/documentation/en/hosting/web.md).

# Web Host

Start the plugin architecture HTTP host, organize the site configuration, and verify the controller and runtime environment.

Web hosting hosts controllers, authentication and authorization, and HTTP protocol extensions. The business interface is provided by the plugin, and the host entrance is responsible for establishing the running pipeline and site context. See [Web Fundamentals](/documentation/en/framework/web.md) for frame capabilities.

## Default Site

The current repository actually provides `web/default`. The management end, merchant end, client end, callback gateway, etc. are examples of site divisions that can be established based on business, and are not complete products that already exist.

The current entry is passed in `host=web`, `site=default`, `daemon=zongsoft.web`, redirect the root path to `/Application` and then run the application:

Source: [hosting/web/default/Program.cs](https://github.com/Zongsoft/hosting/blob/main/web/default/Program.cs#L12) (excerpt; see source for context).

{% code title="Program.cs" %}

```csharp
static void Main(string[] args)
{
	var app = Zongsoft.Web.Application.Web([..args, "host=web", "site=default", "daemon=zongsoft.web"]);

	//如果要启用私有部署模式则打开下行代码注释
	//app.Configuration["Deployment"] = "private";

	app.Map("/", ctx => { ctx.Response.Redirect("/Application"); return Task.CompletedTask; });
	app.Run();
}
```

{% endcode %}

When adding a new site, you should also adjust the `site` and corresponding options in the entry, build/deployment script, and you cannot just copy the directory and then modify the display title.

## Build and Deploy

The project references the output of the adjacent framework by default. The current web project also needs to check its Release reference path. When the plugin reports [`Zongsoft.Web`](https://github.com/Zongsoft/framework/tree/main/Zongsoft.Web) assembly version mismatch, first check the framework output and final DLL, and then redeploy the host.

The runtime directory requires the host's own dependency files, `appsettings.json`, plugin list and resources. Simply copying the business controller DLL is not a substitute for full plugin deployment. See [Deploy Controller Plugins](/documentation/en/framework/web/controllers.md) for a complete example of a stand-alone probe controller.

## Authenticate from HTTP

First confirm the actual listening address from the startup log, and then request `/Application`. `/Modules` and `/Events` can be used to view the corresponding description; access is still affected by the actual deployment and authorization configuration.

{% code title="ProbeApplication.ps1" %}

```powershell
curl.exe --include http://127.0.0.1:8069/Application
```

{% endcode %}

`8069` is a local example port and should be replaced with the actual listening value. For connection failures, 404, 401/403, and 500, prioritize checking the monitoring network, route loading, identity permissions, and server-side exceptions respectively. Do not redeploy all plugins in all situations.

Repository `web/.http` contains the HttpYac request definition, which can also be translated into other HTTP client calls by its method, path, headers, and body. Credentials should be obtained from the current environment, do not copy the default test account or secret to the main example.

## Publishing and Agency

When packaging Linux, the entry name should be `Zongsoft.Hosting.Web` and the service name can be `zongsoft.web`; do not let the generated service point to the class library `Zongsoft.Web.dll`. For the generation rules of service files, see [Packaging Tool](/documentation/en/tools/packager.md).

Reverse proxy environments should check external URLs, forward header trust, HTTPS, request sizes, and timeouts. After enabling OpenAPI or Dashboard, you need to check the corresponding access control; CORS configuration does not replace authentication.

The static file directory prompt caused by empty `wwwroot` does not necessarily affect the pure API service. Do not add irrelevant placeholder services to eliminate the prompt. This should be judged by whether the application actually serves static content.

Related topics: [data service interface](/documentation/en/framework/web/data-services.md), [OpenAPI/gRPC](/documentation/en/framework/web/protocols.md), [Authentication and authorization](/documentation/en/framework/security/authentication.md).

Source references: [Default website](https://github.com/Zongsoft/hosting/tree/main/web/default).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zongsoft.com/documentation/en/hosting/web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
