New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Updated on Dec 10, 2025
This article describes how to seamlessly integrate and configure the Telerik UI Loader for ASP.NET Core in Razor Pages applications.
Razor Pages is an alternative to the MVC pattern that makes page-focused coding easier and more productive. This approach consists of a cshtml file and a cshtml.cs file (by convention, the two files have the same name).
The cshtml.cs file, known as the PageModel, contains handler methods that respond to HTTP requests. These methods are prefixed with On followed by the HTTP verb (for example, OnGet, OnPost, OnPostRead, OnPostCreate).
Handler methods declared in a PageModel can be referenced from any Razor Page using one of the following URL patterns:
Using Url.Page()
Url. Page ( "PageName" , "HandlerName" )
Url. Page ( "/FolderName/PageName" , "HandlerName" )
For example, Url.Page("Index", "Read") references the OnPostRead or OnGetRead handler method in the Index.cshtml.cs file.
Using a query string
Url ( "/PathToPage?handler=HandlerName" )
For example, Url("/Index?handler=Read") references the OnPostRead or OnGetRead handler method in the Index page.
For more information on Razor Pages architecture and concepts, refer to the official Microsoft documentation .
Starting with version 2024 R4, the PDFViewer requires PDF.js version 4+. For more information, refer to the PDF.js processing documentation .
The following example demonstrates how to initialize the PDFViewer in a Razor Pages application by using PDF.JS :
Program.cs HtmlHelper TagHelper PageModel
builder. Services. AddKendo ( x => x. RenderAsModule = true ) ; @page
@model PDFViewerIndexModel
< script src = " https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type = " module" > </ script>
< script src = " https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type = " module" > </ script>
< script src = " https://code.jquery.com/jquery-3.7.1.min.js" type = " module" > </ script>
< script src = " https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type = " module" > </ script>
< script src = " https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type = " module" > </ script>
@inject Microsoft. AspNetCore. Antiforgery. IAntiforgery Xsrf
@ Html. AntiForgeryToken ( )
< h1> PDFViewerPDFJSProcessing</ h1>
@ ( Html. Kendo ( ) . PDFViewer ( )
. Name ( "pdfviewer" )
. PdfjsProcessing ( pdf => pdf. File ( Url. Content ( "~/sample.pdf" ) ) )
. Height ( 1200 )
) @page
@model PDFViewerIndexModel
< script src = " https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.mjs" type = " module" > </ script>
< script src = " https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.3.136/pdf.worker.mjs" type = " module" > </ script>
< script src = " https://code.jquery.com/jquery-3.7.1.min.js" type = " module" > </ script>
< script src = " https://cdn.kendostatic.com/2024.4.1112/js/kendo.all.min.js" type = " module" > </ script>
< script src = " https://cdn.kendostatic.com/2024.4.1112/js/kendo.aspnetmvc.min.js" type = " module" > </ script>
@inject Microsoft. AspNetCore. Antiforgery. IAntiforgery Xsrf
@ Html. AntiForgeryToken ( )
< h1> PDFViewerPDFJSProcessing</ h1>
< kendo-pdfviewer height = " 1200" name = " pdfviewer" >
< pdfjs-processing file = " @ Url. Content ( "~/sample.pdf" ) " />
</ kendo-pdfviewer> public class PDFViewerIndexModel : PageModel
{
public void OnGet ( )
{
}
}
For the complete project, refer to the PDFViewer in Razor Pages example .
The following example demonstrates how to initialize the PDFViewer by using the Telerik Document Processing library in a Razor Pages application.
HtmlHelper TagHelper PageModel
@page
@model PDFViewerDPLModel
@inject Microsoft. AspNetCore. Antiforgery. IAntiforgery Xsrf
@Html. AntiForgeryToken ( )
< h1> PDFViewerDPLProcessing< / h1>
@( Html. Kendo ( ) . PDFViewer ( )
. Name ( "pdfviewer" )
. DplProcessing ( dpl =>
{
dpl. Read ( r => r. Url ( Url. Page ( "PDFViewerDPL" , "Read" ) ) ) ;
} )
) @page
@model PDFViewerDPLModel
@inject Microsoft. AspNetCore. Antiforgery. IAntiforgery Xsrf
@ Html. AntiForgeryToken ( )
< h1> PDFViewerDPLProcessing</ h1>
< kendo-pdfviewer name = " pdfviewer" >
< dpl-processing>
< read url = " @ Url. Page ( "PDFViewerDPL" , "Read" ) " />
</ dpl-processing>
</ kendo-pdfviewer> public class PDFViewerDPLModel : PageModel
{
private IHostingEnvironment _hostingEnvironment;
public PDFViewerDPLModel ( IHostingEnvironment environment)
{
_hostingEnvironment = environment;
}
public void OnGet ( )
{
}
public IActionResult OnGetRead ( int ? pageNumber)
{
string filePath = Path. Combine ( _hostingEnvironment. WebRootPath, "sample.pdf" ) ;
FileStream stream = new FileStream ( filePath, FileMode. Open, FileAccess. Read) ;
JsonResult jsonResult;
FixedDocument doc = FixedDocument. Load ( stream) ;
if ( pageNumber == null )
{
jsonResult = new JsonResult ( doc. ToJson ( ) ) ;
}
else
{
jsonResult = new JsonResult ( doc. GetPage ( ( int ) pageNumber) ) ;
}
return jsonResult;
}
}
For the complete project, refer to the PDFViewer in Razor Pages example .