Create a form with no default action using Html.BeginForm

I want to create a form in which there is no default action. I tried to do Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data", id = "AppForm" }), but assigns the name of the current name of the action of the form action part and displays it as

<form class="ng-pristine ng-valid" id="AppForm" action="/Portal/on/application" enctype="multipart/form-data" method="post" novalidate="novalidate">

</form>

I have two separate buttons on the form, and I follow this article http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-frameworkto create a form, but am not sure how to create one that has no action.

thanks

+4
source share
1 answer

Do you need to use Html.BeginForm()? You can simply do this with html instead HtmlHelper.

<form class="ng-pristine ng-valid" id="AppForm" action="" enctype="multipart/form-data" method="post" novalidate="novalidate">

</form>

If you need to use HtmlHelper, you can override the form action as follows:

@using(Html.BeginForm(null, null, FormMethod.Post, new { @action = "", enctype = "multipart/form-data", id = "AppForm" })) {

}
+4

Source: https://habr.com/ru/post/1607516/


All Articles