Html.beginform v old skool form tag

What is the advantage of using Html.BeginForm?

We have some problems with the html helpers and checking the viewing of the razor generator, and I try my best to see an advantage that would stop us, returning to the old skool form tags.

Has anyone got an argument for or against?

by old skool i mean:

<form action="@Url.Action('Blah')"> 
+6
source share
3 answers

Html.BeginForm is useful because it generates a URL using the routes defined in Global.asax. (or you can expand it with your code)

Using the old tag is neither the worst nor the best in my opinion. You just need to generate your URL manually or using the Url helper. As a result, the html on the page will be the same

 <form ....> html </form> 
+2
source

Html.BeginForm also implements IDisposable , i.e. the form must be closed properly. This may be an insignificant thing, but not closing the Html.BeginForm creates a runtime error where the <form> tag does not close.

+2
source

it makes no difference, the form tag just uses routing to generate the url, so if you use @Url.Action you should go

there are even books that use this simple simple tag and URL helper to generate a route

ASP.NET MVC Website Programming is an Example


Edit

** starting with Mvc 4 there is no difference, up to Mvc 4, Mvc 3, for example, require Html.BeginForm to make an unobtrusive javascript check for work

+2
source

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


All Articles