I'm new to asp.net, and I'm trying to create an API to add a field to my database but I'm getting this message: The requested resource does not support http method 'GET'
. I really need help. Here is my code:
public class PostNewUserController : ApiController
{
RegisterViewModel newUser=new RegisterViewModel() ;
public HttpResponseMessage PostUser(string userName, string password, string confirmPassword)
{
UsersAdminController us = new UsersAdminController();
newUser.Email = userName;
newUser.Password = password;
newUser.ConfirmPassword = confirmPassword;
var user = new ApplicationUser { UserName = newUser.Email, Email = newUser.Email };
var adminresult = us.UserManager.CreateAsync(user, newUser.Password);
var response = Request.CreateResponse<RegisterViewModel>(HttpStatusCode.Created, newUser);
return response;
}
}
And this is the routeConfig code
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Thanks in advance