This question is locked. New answers and comments are not allowed.
Hello,
I am not able to get AntiForgeryToken working with the upload control.
Here is my example.
And here is my onupload function.
I get an error back "A required anti-forgery token was not supplied or was invalid."
Thank you,
mm
I am not able to get AntiForgeryToken working with the upload control.
Here is my example.
<% using (Html.BeginForm("Save", "Customer", FormMethod.Post, new { enctype = "multipart/form-data" }))
{%>
<% Html.EnableClientValidation(); %>
<%: Html.AntiForgeryToken(CommandCenter.Security.Constants.AntiForgeryTokenSalt)%>
<%: Html.Telerik().Upload()
.Name("fCustomers")
.Multiple(false)
.ClientEvents(ce => ce
.OnUpload("d_OnUpload")
)
.Async(a => a
.Save("Upload", "Customer")
.Remove("Remove", "Customer")
.AutoUpload(false)
)
%>
<% } %>
And here is my onupload function.
function d_OnUpload(e) {
e.data = { __RequestVerificationToken: getAntiForgeryToken().value };
}
[HttpPost]
public ActionResult Upload(HttpPostedFileBase fCustomers)
{
var attachmentName = Path.GetFileName(fCustomers.FileName);
var upload_path = ConfigurationManager.AppSettings["upload_dir"];
fCustomers.SaveAs(Path.Combine(upload_path, attachmentName));
return Json(new { fname = attachmentName }, "text/plain");
}
I get an error back "A required anti-forgery token was not supplied or was invalid."
Thank you,
mm