This is a migrated thread and some comments may be shown as answers.

AntiForgeryToken gets lost in editing custom editor

2 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Veteran
Heiko asked on 13 Jun 2013, 03:59 PM
Hi!

I'm new to MVC4 and thus built some little demo including a Kendo UI Grid and a partial view which serves as a custom editor. Everything works perfect except that the AntiForgeryToken gets lost on the way.

This is my definition of the grid:
@(Html.Kendo().Grid(Model)
    .Name("grdProducts")
    .Columns(columns =>
        {
            columns.Bound(p => p.Name);
            columns.Bound(p => p.ProductType);
            columns.Bound(p => p.SellStartDate);
            columns.Bound(p => p.SellEndDate);
            columns.Command(command => command.Edit()).Width(160);
        })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable
        .Mode(GridEditMode.PopUp)
        .DisplayDeleteConfirmation(true)
        .TemplateName("ProductEditor")
        .Window(w => w
            .Width(700)
            .Title("Edit Product")))
    .Pageable(pa => pa.Numeric(false).PageSizes(new [] {5,10,20}))
    .Scrollable(scr => scr.Height(430).Virtual(false))
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
    .DataSource(dataSource => dataSource
        .Ajax()
        .AutoSync(false)
        .Batch(false)
        .PageSize(20)
        .ServerOperation(false)
        .Model(model =>
            {
                model.Id(p => p.Id);
                model.Field(p => p.Id).Editable(false);
                model.Field(p => p.CategoryName).Editable(false);
                model.Field(p => p.ProductType).DefaultValue((int)ProductTypeEnum.Cameras);
            })
        .Create(create => create.Action("EditingCreate", "Product"))
        .Read(read => read.Action("EditingRead", "Product"))
        .Update(update => update.Action("EditingUpdate", "Product"))
    )
)
And this is the start of my partial view named "ProductEditor.cshtml" saved in subdir "EditorTemplates":
@model _ProductStore.Infrastructure.Models.Products.Product

@{
    ViewBag.Title = "Edit";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
 
    <fieldset>
... all labels and fields...
    </fieldset>
}
The popup opens as it should and everything works fine except that the hidden input for AntiForgeryToken looks like this:
<input name="__RequestVerificationToken" type="hidden" data-bind="value:__RequestVerificationToken" value=""/>
In other words: the value is empty. Placing the AntiForgeryToken helper somewhere else in my views it is working perfectly.

What am I doing wrong?

Regards
Neils






2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 17 Jun 2013, 08:11 AM
Hello Neils,

Similar question is covered here:

http://www.kendoui.com/forums/ui/grid/kendo-grid-antiforgerytoken.aspx


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Heiko
Top achievements
Rank 1
Veteran
answered on 24 Jun 2013, 07:38 AM
Thanks, that did the trick!
Tags
Grid
Asked by
Heiko
Top achievements
Rank 1
Veteran
Answers by
Petur Subev
Telerik team
Heiko
Top achievements
Rank 1
Veteran
Share this question
or