Like partial views, view components can also display HTML. Since the display provided by your view component has a valid form tag in it, yes, you can submit forms.
@model YourNamespace.LoginVM <form asp-controller="Home" asp-action="Login"> <input asp-for="Name" /> <input asp-for="Password" /> <input type="submit" /> </form>
You need to make sure that you have a HomeController login action method
[HttpPost] public ActionResult Login(LoginVM model) {
It is important to remember that you should not name this component of the view inside another form tag. General rule: you should not embed forms .
<form id="main-form" asp-controller="main" asp-action="submit" method="post"> <input asp-for="LocationName" /> <input type="submit" /> </form> @Component.Invoke("Login")
Shyju source share