ASP.NET AJAX.BeginForm sends request twice and add duplicate entries

Hi, I was working with Ajax.BeginForm and found that when I submit a form it was adding same entry twice. I tried to figure out but didn’t get some proper solution because it was working fine at my local. When I pushed my code to live it was inserting a twice entry in the database.

After a few hours I get some idea from google research and found I added jquery.unobtrusive-ajax.min.js twice. One in my _Layout.cshtml page and one in partial view. So your browser executes the javascript code inside twice which hit twice on the form click event inserting two entries instead of one.

So you can remove one js file either from _Layout.cshtml page or parital view. It will work for sure.

If it solves your problem don’t forget to share and comment. cheers…

Posted by | View Post | View Group