jquery - my Ajax call does not hit breakpoint in controller action -


hi have following code in controller httppost action trying save applicant detail in database using ajax in mvc entity framework

 [httppost]     [validateantiforgerytoken]     public async task<jsonresult> saveapplicantdetails()     {         try         {             careerapplicant ca = new careerapplicant();             if (request.files.count > 0)             {                 var file = request.files[0];                 ca.resumelink = uploadfile.uploaddocfile(file, "uploads");             }              ca.email = request["email"].tostring();             ca.contactno = request["contact"].tostring();             ca.name = request["name"].tostring();             ca.careerid = convert.toint32(request["careerid"].tostring());             db.careerapplicants.add(ca);             db.savechanges(); 

and following ajax call

 $("#btnsave").click(function () {         if ($("#form1").valid()) {             var fd = new formdata();             var files = $("#flresume").get(0).files; // file input in can select multiple files.             fd.append("name", $("#txtname").val());             fd.append("email", $("#txtemail").val());             fd.append("contact", $("#txtcontact").val());             fd.append("careerid", $(this).attr("careerid"));              (var = 0; < files.length; i++) {                 fd.append("uploads" + i, files[i]);             }             alert("hit1");             $.ajax({                 type: "post",                 datatype: 'json',                 url: '@url.action("saveapplicantdetails", "careers")',                contenttype: false,                 processdata: false,                 data: fd.serialize(),                 success: function (data) {                     alert("suc called");                     if (data == "success") {                         alert("suc called inner");                         alert("thanks intrest, applied successfuly.");                     }                     else {                         alert("suc failed called");                         alert("error occured while saving data.");                     }                 }             })         }         else {             alert('the form not valid');         }     }); }); 

when trying hit breakpoint in controller doesnt hit...i dont know why..seeking here thank you

i removed [validateantiforgerytoken] controller action , worked ..thank guruprasad making efforts :) appreciate

[httppost] public async task<jsonresult> saveapplicantdetails() {     try     {         careerapplicant ca = new careerapplicant();         if (request.files.count > 0)         {             var file = request.files[0];             ca.resumelink = uploadfile.uploaddocfile(file, "uploads");         }         ca.email = request["email"].tostring();         ca.contactno = request["contact"].tostring();         ca.name = request["name"].tostring();         ca.careerid = convert.toint32(request["careerid"].tostring());         db.careerapplicants.add(ca);         int res = await db.savechangesasync();         if (res > 0)         {             string mailto = request["email"].tostring(); /*configurationmanager.appsettings["sendmailto"].tostring();*/             new thread(() =>             {                 emailmessage emailmsg = new emailmessage();                 string messagestring = emailmsg.readfile("mailformat.html");                 career c = db.careers.where(x => x.id == ca.careerid).firstordefault();                 messagestring = messagestring.tostring().replace("{title}", c.title);                 messagestring = messagestring.tostring().replace("{datetime}", datetime.now.tostring());                 messagestring = messagestring.tostring().replace("{username}", ca.name);                 messagestring = messagestring.tostring().replace("{email}", ca.email);                 messagestring = messagestring.tostring().replace("{contact}", ca.contactno);                  emailmsg.sendmailmessage(ca.name, "applicant person detail.", messagestring, mailto);            }).start();         }     }     catch (exception)     {         return json("error");     }     return json("success"); } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -