# System.Web.Razor

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Web.Razor` is a NuGet package dependency referenced by the legacy-format `Pams.API` project. It supports Razor view parsing and compilation for server-rendered content in the ASP.NET application.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant API as Pams.API
    participant Razor as System.Web.Razor
    participant View as Razor View

    Client->>API: Request rendered page
    API->>Razor: Parse Razor template
    Razor->>View: Compile and render markup
    View-->>API: Rendered HTML
    API-->>Client: HTML response
```

## Usage

```ts
async function loadRazorPage(path: string): Promise<string> {
  const response = await fetch(path, {
    headers: {
      Accept: "text/html",
    },
  });

  if (!response.ok) {
    throw new Error(`Request failed: ${response.statusText}`);
  }

  return response.text();
}

loadRazorPage("/reports")
  .then((html) => {
    document.documentElement.innerHTML = html;
  })
  .catch((error) => {
    console.error("Could not load Razor-rendered page.", error);
  });
```

## AI Coding Instructions

- Keep the `System.Web.Razor` package reference aligned with the ASP.NET framework version used by `Pams.API`.
- Treat Razor templates as server-side assets; JavaScript clients should request the rendered HTML or API data rather than import this package.
- Check Razor syntax and view compilation errors when changing server-rendered pages.
- Avoid mixing Razor dependencies with newer ASP.NET Core Razor package names unless the project framework is migrated.
