Form is submitted twice to mvc

I have an ajax form when submit button is clicked. It is dispatched twice means the control is entering the controller action method twice, I cannot find a solution.

+3


source to share


1 answer


I suspect you have jquery-unobtrusive-ajax.js that gets included multiple times in the page, in the layout of the layout, and also in the child view, causing the form to publish multiple times.

in this case it is included twice, so the form is submitted twice. you have to make sure it is only enabled once, enable it _Layout.cshtml

and remove it from all child views.



These scripts are included in the view by default _Layout.cshtml

, so if you re-include them in the child view it will result in a double form post

+12


source







All Articles