IHtmlHelper.BeginForm Method

Definition

Renders a <form> start tag to the response. When the user submits the form, the action with name actionName will process the request.

public:
 Microsoft::AspNetCore::Mvc::Rendering::MvcForm ^ BeginForm(System::String ^ actionName, System::String ^ controllerName, System::Object ^ routeValues, Microsoft::AspNetCore::Mvc::Rendering::FormMethod method, Nullable<bool> antiforgery, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Mvc.Rendering.MvcForm BeginForm (string actionName, string controllerName, object routeValues, Microsoft.AspNetCore.Mvc.Rendering.FormMethod method, bool? antiforgery, object htmlAttributes);
abstract member BeginForm : string * string * obj * Microsoft.AspNetCore.Mvc.Rendering.FormMethod * Nullable<bool> * obj -> Microsoft.AspNetCore.Mvc.Rendering.MvcForm
Public Function BeginForm (actionName As String, controllerName As String, routeValues As Object, method As FormMethod, antiforgery As Nullable(Of Boolean), htmlAttributes As Object) As MvcForm

Parameters

actionName
String

The name of the action method.

controllerName
String

The name of the controller.

routeValues
Object

An Object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the Object. This Object is typically created using Object initializer syntax. Alternatively, an IDictionary<TKey,TValue> instance containing the route parameters.

method
FormMethod

The HTTP method for processing the form, either GET or POST.

antiforgery
Nullable<Boolean>

If true, <form> elements will include an antiforgery token. If false, suppresses the generation an <input> of type "hidden" with an antiforgery token. If null, <form> elements will include an antiforgery token only if method is not Get.

htmlAttributes
Object

An Object that contains the HTML attributes for the element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

An MvcForm instance which renders the </form> end tag when disposed.

Remarks

In this context, "renders" means the method writes its output using Writer.

Applies to