Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form is submitted twice mvc

I have a ajax form when its submit button is clicked It is submitted twice means that control comes in controller action method twice, I am unable to find solution.

like image 916
tspga Avatar asked Sep 10 '14 10:09

tspga


1 Answers

I suspect you have jquery-unobtrusive-ajax.js included multiple times on page, in master layout and also in the child view which is causing the form to be posted multiple times.

in this case it is included two times, so form is posting two times. you have to make sure that it is included only once, include it _Layout.cshtml and remove from all child views.

These scripts are by default included in _layout.cshtml view so if you include them again in child view it will cause it to post form twice

like image 178
Ehsan Sajjad Avatar answered Oct 14 '22 14:10

Ehsan Sajjad