ExpertPdf Anywhere ASP.NET Core samples · .NET 10 and .NET 11

ExpertPdf Anywhere - Helper Page - View HTTP Headers - C# / ASP.NET Sample

This page shows the HTTP Headers sent to it:

Accept: */*
Connection: keep-alive
Host: samples.html-to-pdf.net
User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Accept-Encoding: gzip, br, zstd, deflate
Cookie: .AspNetCore.Antiforgery.pYv0q5nZIsw=CfDJ8PJNlcHp4PVDknI85UeDnSJCwwgElki-3ne8Nny21MIuK8Pf8FH8aL1vIlnP0GMQtBZ6fnJuqCdThHf8gCMOK0euBNvoOQb4vWFMOhrgybeLxLDOZhN163U_vAE_PWVEOWElMEuplDSbAgOLn9r_dvU
MS-ASPNETCORE-TOKEN: 0de6031b-38b9-49bb-80ae-e9f31da1e5a6
X-Original-Proto: http
X-Original-For: 127.0.0.1:63038

C# code of this sample

Pages/ViewHttpHeaders.cshtml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Primitives;

namespace ExpertPdf.Samples.Pages
{
    public class ViewHttpHeadersModel : PageModel
    {
        public void OnGet()
        {
            string headers = string.Empty;
            foreach (KeyValuePair<string, StringValues> header in Request.Headers)
            {
                headers += "<br/>" + header.Key + ": " + header.Value;
            }

            ViewData.Add("HeadersValue", headers);
        }
    }
}