Include Authorization token to header

28 Oct 20251 minute to read

The PDF Viewer component enables adding authorization tokens to each AJAX request through the ajaxHeaders collection in AjaxRequestSettings, ensuring the header is appended to every call initiated by the viewer.

Use the following steps to configure the authorization token for the PDF Viewer control.

Step 1: Follow the steps in the Getting Started with ASP.NET MVC PDF Viewer guide to configure a basic ASP.NET MVC project with the PDF Viewer component.

Step 2: Add the following script after the PDF Viewer instance is rendered to include the authorization token in subsequent requests.

@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/PdfViewer/")).DocumentPath("PDF_Succinctly.pdf").AjaxRequestSettings(new PdfViewerAjaxRequestSettings { WithCredentials = true, AjaxHeaders = new object[] { new { headerName = "Testingabc", headerValue = "Testing123" } } }).Render()

Download the sample how to include authorization token