Posts

Posts mit dem Label "RAZOR" werden angezeigt.

ASP.NET RAZOR: Multiple page methods for POST / GET & Ajax call - possible issues

Bild
In my current project I need a additional page method for POST requests beside the default page POST method. Actually I don't use any page POST methods because I use in the most of the times the WebAPI REST endpoints for all CRUD operations. But for the new requirement I need a POST method to send out an E-Mail message from a clientside call. For the client call I used jQuery and implemented the following code: $.ajax({   url: "/WebForm/FormData/SendMessage",   type: "POST",   contentType: "application/json; charset=utf-8",   data: options.data,   success: function (d) {...},   error: function (d) { ...} }); Page url: /WebForm/FormData In the page model class I added a new post method with the prefix "OnPost" to mark the method as POST-method: public async Task<JsonResult> OnPostSendMessage([FromBody] CloudFormMessageReply messageToSend) { ... } I thought everything is perfect in place and I tested my implementation but nothing happen...