asp.net web api - Web.API works in some deployments but returns 404 in others -


i have asp.net webforms app distributed. new version adds web.api , users have been playing beta. in beta installations works fine, installs web.api calls return http 404 not found errors. can't figure out why web.api calls fail on servers works fine on others.

my guess there kind of server configuration breaking routing, can't figure out is. i've rdp'd 1 of these sites , can't find obvious.

this example api call:

get http://site.com/api/events/27

the code:

namespace galleryserverpro.web.api {   public class eventscontroller : apicontroller   {     public string get(int id)     {       return "event data id " + id;     }   } } 

the route definitions, called init event of custom http module named gsphttpapplication:

private void registerroutes(routecollection routes) {   routes.maphttproute(     name: "galleryapi1",     routetemplate: "api/{controller}"   );    routes.maphttproute(     name: "galleryapi2",     routetemplate: "api/{controller}/{id}",     defaults: new { },     constraints: new     {       id = @"\d*",     }   );    routes.maphttproute(     name: "galleryapi3",     routetemplate: "api/{controller}/{id}/{action}",     defaults: new     {     },     constraints: new     {       id = @"\d*"     }   );    // add route support things api/meta/galleryitems/   routes.maphttproute(     name: "galleryapi4",     routetemplate: "api/{controller}/{action}",     defaults: new     {     },     constraints: new     {     }   ); } 

the example above should match route named galleryapi2, , said in installations does.

i know webdav can cause trouble (405 errors), remove in web.config:

<system.webserver>   <modules>     <remove name="webdavmodule" />     <add name="gspapp" type="galleryserverpro.web.httpmodule.gsphttpapplication, galleryserverpro.web" />   </modules>   <handlers>     <remove name="webdav" />     <remove name="extensionlessurlhandler-integrated-4.0" />     <remove name="extensionlessurlhandler-isapi-4.0_32bit" />     <remove name="extensionlessurlhandler-isapi-4.0_64bit" />     <add name="extensionlessurlhandler-isapi-4.0_32bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness32" responsebufferlimit="0" />     <add name="extensionlessurlhandler-isapi-4.0_64bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework64\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness64" responsebufferlimit="0" />     <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="get,head,post,debug,put,delete,patch,options" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" />   </handlers>   ... </system.webserver> 

so comes down figuring out why configuration works web installs , not others.

roger


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -