I facing an issue with the ASP.NET BeginForm
helper.
I try to create a form that should point to /Project/Delete
and I tried the following statemant to reach this target:
@using (Html.BeginForm("Delete", "Project"))
{
}
<form action="@Url.Action("Delete", "Project")"></form>
But unfortunately both rendered actions points to /Projects/Delete/LocalSqlServer
, which is the url of site called in the browser
<form action="/Project/Delete/LocalSqlServer" method="post"></form>
I really dont know why the rendered action points to itself instead of the given route.I already read all posts (which I found) on google and SO, but found no solution.
This is the only route defined:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
And this are my controller
[HttpGet]
public ActionResult Delete(string id)
{
return View(new DeleteViewModel { Name = id });
}
[HttpPost]
public ActionResult Delete(DeleteViewModel model)
{
_configService.DeleteConnectionString(model);
return null;
}
I am using .NET 4.6.2.
I would really appreciate your help.
Thanks Sandro