DEV Community 👩‍💻👨‍💻

Joe Enos
Joe Enos

Posted on

Razor Pages AJAX

With ASP.NET Razor Pages, you get some built-in protections that you don't get with MVC. CSRF protection is there by default, and that's generally a really good thing. However, it makes AJAX a little more difficult, since you can't make a regular AJAX call to a page, the way you can to an MVC controller action, passing in whatever you want from JavaScript.

Here are a few ways to run your AJAX calls, while still following the rules necessary for the CSRF handling.

Latest comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.