asp.net web api - Web API 404 Error -
i getting 404 error while calling web api method...
below code
web api controller:
[enablecors(origins: "*", headers: "*", methods: "*")] public class homecontroller : apicontroller { private homedataprovider homedataprovider = new homedataprovider(); // api/<controller> [allowanonymous] public ienumerable<string> get() { return new string[] { "value1", "value2" }; } [allowanonymous] [httppost] //[authorization] public list<user> test_api(homesearch searchparam) { list<user> test_user = null; try { test_user = homedataprovider.test_dataprovider(searchparam); } catch (exception ex) { throw ex; } { } return test_user; } web api config
// web api configuration , services // web api routes config.maphttpattributeroutes(); config.routes.maphttproute( name: "api default", routetemplate: "webapi/{controller}/{id}", defaults: new { id = routeparameter.optional } ); } } web api web.config
<appsettings></appsettings> <system.web> <compilation debug="true" targetframework="4.5.2" /> <httpruntime targetframework="4.5.2" /> <rolemanager enabled="false" /> <!--<rolemanager defaultprovider="aspnetwindowstokenroleprovider" enabled="true" />--> </system.web> <system.webserver> <validation validateintegratedmodeconfiguration="false" /> <modules runallmanagedmodulesforallrequests="true"> </modules> <handlers> </handlers> </system.webserver> using windows 10, vs 2015, iis 10 url calling http://localhost/webapi/home/get error: 404, static handler error i searched , tried options on stackoverflow , other sources in vain
i figured out answer
actually: in web api settings: selected : local iis, localhost/webapi... create virtual directory route localhost/webapi/webapi/home/get alex , probable solutions posted...
Comments
Post a Comment