New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Upload in Razor Pages
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 design, the two files have the same name).
You can seamlessly integrate the Telerik UI Upload for ASP.NET Core in Razor Pages applications.
This article describes how to configure the Upload component in a Razor Pages scenario.
For the complete project, refer to the Upload in Razor Pages example.
cshtml
@page
@model Telerik.Examples.RazorPages.Pages.Upload.UploadIndexModel
@{
ViewData["Title"] = "UploadIndex";
}
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()
<h1>UploadIndex</h1>
@(Html.Kendo().Upload()
.Name("files")
.Async(a=>
a.SaveUrl("./UploadIndex?handler=Save")
.RemoveUrl("./UploadIndex?handler=Remove")
)
.Validation(validation => validation.AllowedExtensions(new string[] { ".jpg" , ".png", ".jpeg" }))
.Validation(validation => validation.MaxFileSize(2000000))
)