SaaS CMS has officially launched! Learn more now.

ajax post call to epi server block controller not working


I am trying to send an ajax POST request from javascript (razor view ) to epi server block controller, it is not hitting. I am only to able to send GET request. Below is the code snippet for controller for javascript

 $.ajax({            url: '/BreadcrumbAndSharing/SendEmail/',            type: 'GET',            data: JSON.stringify({                name: "Tommy",                birthday: new Date(1921, 0, 1),                hobbies: ["Pinball", "Holiday camp"]            }),            contentType: 'application/json',            error: function (xhr) {                alert('Error: ' + xhr.statusText);            },            success: function (result) {                CheckIfInvoiceFound(result);            },            async: true,            processData: false        });

public ActionResult SendEmail(Person person)

Object obj = JsonConvert.DeserializeObject(Request.Params[0].ToString());
Person objperson = JsonConvert.DeserializeObject(Request.Params[0].ToString());
string subject = "test email";
string body = "testing this email";


Any help is higly appreciated in this regard

Dec 30, 2014 7:47

Change this_:
$.ajax({            url: '/BreadcrumbAndSharing/SendEmail/',            type: 'GET'

$.ajax({            url: '/BreadcrumbAndSharing/SendEmail/',            type: 'POST'

And then decorate your action with this

public ActionResult SendEmail(Person person)


Dec 30, 2014 13:56

Thanks, i did tried these options as already. Code shared is for GET request, whcih is working POST is not working at all. if you track it in fiddler  it says HTTPS status code 301 got POST and then after that it issue a GET request automatically which says 404, (which is obvious i think becuase action is decorated with POST attribute)

Dec 31, 2014 5:39
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.