Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IHtmlHelper.BeginForm Method

Definition

Namespace:
Microsoft.AspNetCore.Mvc.Rendering
Assembly:
Microsoft.AspNetCore.Mvc.ViewFeatures.dll
Package:
Microsoft.AspNetCore.Mvc.ViewFeatures v1.0.0
Package:
Microsoft.AspNetCore.Mvc.ViewFeatures v1.1.0
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Mvc.ViewFeatures v2.0.0
Package:
Microsoft.AspNetCore.Mvc.ViewFeatures v2.1.0
Package:
Microsoft.AspNetCore.Mvc.ViewFeatures v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Source:
IHtmlHelper.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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


Feedback

Was this page helpful?