How to install FormMethod.Get using Html.BeginForm

I would like my form to do Get rather than Post (this is the request field the user submits)

I know I can do it with

<% using(Html.BeginForm(action, controller, FormMethod.Get) {%> 

However, I would prefer not to specify an action / controller, and there seems to be no overload that only accepts FormMethod.

This is MVC 1.0 (and without futures)

+4
source share
2 answers

There is no such overload in the structure. However, if you submit the action and controller as null , the structure will do what you want. If you don't like this, you can create this extension yourself:

 public static MvcForm BeginForm(this HtmlHelper htmlHelper, FormMethod method) { return htmlHelper.BeginForm(null, null, method); } 
+7
source

You can use <form method="get" action="<%= Url.Action("Action", "Controller")%>" >

+2
source

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


All Articles