I Have this in a view in an area
<form action='@Url.Action("/DeleteCoverage")'></form>
but this gives only the following html
<form action=''></form>
but the following code
@using (Html.BeginForm("DeleteCoverage", "Coverage", new { area = "Coverage" }, FormMethod.Post, new { id = "delform" }))
gives html
<form action="/Coverage/DeleteCoverage/af361feb-1818-430b-803c-e332a162b0e2" id="delform" method="post">
I get this HTML only if i add a route for this method. Other wise it just becomes action=""
Why i am not getting proper HTML if I don’t add route?
You are incorrectly using the
Url.Actionhelper. This helper has several overloads and expects you to pass action, controller, route values, … Currently you are passing/DeleteCoveragewhich is invalid action name (action names cannot start with/).So pick one of the overloads and use it correctly:
Oh and by the way you should probably use
Html.BeginFormto generate your form tags instead of hardcoding them.