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

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

This article showcases how to configure a basic Chat component in a Razor Pages scenario.

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

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

    @(Html.Kendo().Chat()
        .Name("chat")
        .Toolbar(toolbar =>
        {
            toolbar.Toggleable(true);
            toolbar.Scrollable(true);
            toolbar.Buttons(buttons =>
            {                
                buttons.Add().Name("Bold").IconClass("k-icon k-i-bold");
                buttons.Add().Name("Italic").IconClass("k-icon k-i-italic");
                buttons.Add().Name("Underline").IconClass("k-icon k-i-underline");
            });
        })   
    )
    @page
    @IndexModel
    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <kendo-chat name="chat">
        <toolbar toggleable="true" scrollable="true">
            <buttons>
                <button name="Bold" icon-class="k-icon k-i-bold" />
                <button name="Italic" icon-class="k-icon k-i-italic" />
                <button name="Underline" icon-class="k-icon k-i-underline" />
            </buttons>
        </toolbar>
    </kendo-chat>
    public void OnGet()
    {

    }

See Also

In this article