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.

Top comments (0)

🌚 Life is too short to browse without dark mode