I have created a new web application with MVC template and core references having MVC and Web API.
I want to handle all the business logic through Web API controller. I have a login page view, where on form submit i want to make a call to the Web API method with the form data.
Login.cshtml
<form action="/api/Authorization/Login" method="post">
<div>
UserName: <input type="text" name="UserName" id="UserName" value="" />
</div>
<div>
Password: <input type="password" name="UserPassword" id="UserPassword" value="" />
</div>
<div>
<input type="submit" name="BtnSubmit" value="Login" />
</div>
I have added a Web API controller in the controller folder with the name 'Authorization' and on the above form submit, I'm not able to reach the method 'Login'.
Authorization Web API controller:
public class AuthorizationController : ApiController
{
public ActionResult Login(string UserName, string UserPassword)
{
// method logic
}
}
On form submit ending up with the following screen,

Please let me know what am i missing here so that i can reach the method defined under the api controller?
Also have not added any new route configs, the only config present in webApiConfig.cs is,
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);