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

Razor Page

This article describes how to configure the Telerik UI Dialog HtmlHelper for ASP.NET Core in a RazorPage scenario.

The example below demonstrates how to pass antiforgery token when an action from the Dialog is clicked. See the implementation details in the example below, and for the full project with RazorPages examples, visit our GitHub repository.

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

    @(Html.Kendo().Dialog()
        .Name("dialog")
        .Title("Data Update")
        .Content("<p>Would you like to confirm updating the data?<p>")
        .Width(400)
        .Modal(false)
        .Actions(actions =>
        {
            actions.Add().Text("Cancel");
            actions.Add().Text("Send data").Primary(true).Action("onSendData");
        })
    )   

    <script>
        function onSendData() {
            $.ajax({
                url: "/Dialog/DialogIndex",
                type: "POST",               
                headers: {
                    RequestVerificationToken: kendo.antiForgeryTokens().__RequestVerificationToken
                },
                dataType: "json"
            });
        }
    </script>

    public void OnPost()
        {
            ....
        }

See Also

In this article
Not finding the help you need? Improve this article