6

I want to create a form which has no default action in it. I tried doing Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data", id = "AppForm" }) but it assigns the current action method name to the action part of the form and renders 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 am following this article http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework to create a form but not sure how to create one which has no action.

Thanks

SP1
  • 1,182
  • 3
  • 22
  • 47

1 Answers1

7

Do you have to use Html.BeginForm()? You could just do it with html instead of using the HtmlHelper.

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

</form>

If you have to use the HtmlHelper, you can override the form action like this:

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

}
Peter
  • 12,541
  • 3
  • 34
  • 39