Product Bundles
DevCraft
All Telerik .NET and Kendo UI JavaScript components and AI Tools in one package.
Kendo UI
Bundle of AI Tools plus four JavaScript UI libraries built natively for jQuery, Angular, React and Vue.
Build JavaScript UI
Javascript
Telerik
Build modern .NET business apps
.Net Web
Cross-Platform
Desktop
Reporting and Documents
AI for Developers & IT
Ensure AI program success
AI Coding
AI Engineering
Additional Tools
Enhance the developer and designer experience
Testing & Mocking
Debugging
UI/UX Tools
CMS
Free Tools
Support and Learning
Productivity and Design Tools
Hi Lenny,Thank you for the details provided.
In order to achieve the described behavior, I would recommend to configure the anti-forgery settings as follows:
In your Startup.cs or Program.cs:
public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddAntiforgery(options => { options.HeaderName = "X-CSRF-TOKEN"; }); }
var token = $('input[name="__RequestVerificationToken"]').val(); e.XMLHttpRequest.setRequestHeader("X-CSRF-TOKEN", token);
@Html.AntiForgeryToken()
[HttpPost] [ValidateAntiForgeryToken] public IActionResult Upload(IFormFile file) { }
Kind Regards,
Anton Mironov
Thanks. I figured it out. I added this bit of script to the Upload client side event handler.
Hi Lenny,Thank you for sharing the code with the community.
Best Regards,Anton Mironov
Hi Lenny,
Thank you for the details provided.
In order to achieve the described behavior, I would recommend to configure the anti-forgery settings as follows:
In your Startup.cs or Program.cs:
public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddAntiforgery(options => { options.HeaderName = "X-CSRF-TOKEN"; }); }var token = $('input[name="__RequestVerificationToken"]').val(); e.XMLHttpRequest.setRequestHeader("X-CSRF-TOKEN", token);Ensure the anti-forgery token is available in the View:
[HttpPost] [ValidateAntiForgeryToken] public IActionResult Upload(IFormFile file) { }Kind Regards,
Anton Mironov
Thanks. I figured it out. I added this bit of script to the Upload client side event handler.
var xhr = e.XMLHttpRequest;if(xhr) {
xhr.addEventListener("readystatechange", function (e) {
if (xhr.readyState == 1 ) {
xhr.setRequestHeader('RequestVerificationToken', getAntiForgeryToken());
}
});
}
Hi Lenny,
Thank you for sharing the code with the community.
Best Regards,
Anton Mironov