New to Telerik UI for ASP.NET Core? Download free 30-day trial

ImageEditor 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 ImageEditor for ASP.NET Core in Razor Pages applications.

This article describes how to configure the ImageEditor component in a Razor Pages scenario.

For the complete project, refer to the ImageEditor in Razor Pages example.

The example below demonstrates how to configure the ImageEditor to forward the content to a proxyURL in a Razor Pages scenario even if the browser supports saving files locally.


    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    @(Html.Kendo().ImageEditor()
        .Name("imageEditor")
        .Height(900)
        .SaveAs(s => {
            s.FileName("image_edited.png");
            s.ForceProxy(true);
            s.ProxyURL(Url.Page("ImageEditorIndex", "Save"));
        })
        .ImageUrl(@Url.Content("~/images/2.jpg"))
    )

    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <kendo-imageeditor name="imageEditor" height="900" image-url="@Url.Content("~/image/2.jpg")">
        <save-as file-name="image.png" 
                 force-proxy="true"
                 proxy-url="@Url.Action("ImageEditorIndex","Save")"/>
    </kendo-imageeditor>

    public IActionResult OnPostSave(string contentType, string base64, string fileName)
    {
        var fileContents = Convert.FromBase64String(base64);

        return File(fileContents, contentType, fileName);
    }

See Also

In this article