Assuming your view is strongly typed to a view model like
public class CreateProduct
{
public string Name { set; get; }
}
And you are passing an object of this to the view from your action method.
@model CreateProduct
<form asp-action="create" asp-controller="Home" >
<input type="text" asp-for="Name"/>
<input type="submit"/>
</form>
This will generate the below markup.
<form action="/Home/create" method="post">
<input type="text" id="Name" name="Name" value="" />
<input type="submit"/>
<input name="__RequestVerificationToken" type="hidden" value="ThisWillBeAUniqueToken" />
</form>
If you want the input field to be rendered with a default value, you can set the Name property value of your view model in the action method.
public IActionResult Create()
{
var vm = new CreateProduct { Name="IPhone"};
return View(vm);
}
Form submission & Model binding
Model binding will work fine if you use CreateProduct
as your HttpPost action method parameter/a parameter named name