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
Agent and App Development Solutions
Build. Accelerate. Govern.
AI-Ready Application Experiences
AI-Assisted SDLC
Agent Governance and Control
Telerik
Build modern .NET business apps
.Net Web
Desktop
Reporting and Documents
Cross-Platform
Additional Tools
Enhance the developer and designer experience
Testing & Mocking
CMS
Debugging
UI Tools
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