I have a web API (.NET Framework 4.0, MVC Web Application, visual studio 2010 sp1)
And there is my WebApiConfig
code:
public static void Register(HttpConfiguration config)
{
//config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
And for example this is one of my Controller's Methode Code:
[AcceptVerbs("Post")]
[ActionName("GetAccountTypeById")]
public static clsAccountType GetAccountTypeById(int AccountTypeId)
{
SqlParameter[] param = { new SqlParameter("@Id", AccountTypeId) };
DataTable dt = null;
dt = Execute.ExecuteSelect("SP_GetAccountTypeById", param);
if (dt.Rows.Count > 0)
{clsAccountType item = new clsAccountType(Convert.ToInt32(dt.Rows[0]["Id"]), dt.Rows[0]["Name"].ToString());
return item;
}
else
return null;
}
The problem is when I call this URL:
http://localhost:1387/api/AccountType/GetAccountTypeById
From browser show me this error:
The requested resource does not support http method 'GET'