What is the correct way to handle forms in ASP.NET MVC?

Forms + ASP.NET MVC = Confuses me:

  • What are the preferred ways to configure your controller action for messages on the form?

    • Do I need to specify an attribute that has [AcceptVerbs (HttpVerbs.Post)]?
    • Should the controller action accept "FormCollection" or use ModelBinders?
    • If I have to use ModelBinders, how?
  • How to customize a form in a view?

    • Should I use Html helpers like Html.BeginForm / Html.EndForm, or just specify the form tag itself?
    • How do you define the controller and the action that should be used in the form (with helpers or with a manual form tag)?

Can someone please show me how simple view is with form ~ and ~ its corresponding controller action?

I am trying to write a form with one text field, which I can submit to the Home / Create action and pass a line from the text field.

+3
source share
2 answers

ScottGu handling forms and post-scripting is exactly what you are looking for. There are also script publishing forms , and although it was written for preview 5, it is still mostly valid.

+4
source

The AccountController.LogOn and .Register method templates, along with the corresponding views, should give you the simple introduction you need.

0
source

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


All Articles