Hi
I am using .net core Razor pages and want to add an image browser to an email editor.
The page has an anti-forgery token and other elements on the page use ajax to pass this to the page behind to process data.
Initially when I was trying to call the image browser in a similar way I was getting 400 errors. I then added the attribute [IgnoreAntiforgeryToken(Order = 1001)] to the code behind and was able to hit the code. This is the razor code I am using in order to generate the editor.
@(Html.Kendo().Editor()
.Name("email-editor")
.HtmlAttributes(new { style = "width: 100%; height: 420px" })
.Tools(tools => tools
.Clear()
.Bold().Italic().Underline()
.JustifyLeft().JustifyCenter().JustifyRight()
.InsertUnorderedList().InsertOrderedList()
.Outdent()
.Indent()
.CreateLink().Unlink()
.InsertImage())
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/UserFiles/Images/{0}")
.Transport(t =>
{
t.Read(r => r.Url("./EmailOverview?handler=ReadImage"));
})
))
This is the most basic method in the code behind so I can call it.
public async Task<JsonResult> OnPostReadImage()
{
return new JsonResult(true);
}
Is there some syntax I can use to pass in an anti-forgery token with the call. Or can I pass in some additionally parameters with jquery?
Many thanks