c# - WebApi Attribute Routing for URLs with *.js -


ok it's not that funny ending...

i trying emulate ror-based service in .net webapi. ruby implementation of service supposed return json document url of:

http://myserver/api/assessments/{id}.js 

note .js @ end.

i made routeattribute decoration on api controller so:

[route("~/api/assessments/{id}.js")] public async task<httpresponsemessage> getassessment(int id) {     . . . } 

...but i'm getting 404 error. suspected might because request ended in "js", after bit of research found should set routecollection.routeexistingfiles true... did not seem have effect. still getting 404.

am right? .js ending causing 404? how can around this? pure webapi project, it's not i'm using javascript in anyway.

do have following in web.config? setup routing project work , line caused me sorts of hell because not present:

<configuration>   ...   <system.webserver>     <modules runallmanagedmodulesforallrequests="true">     ...     </modules>   </system.webserver> </configuration> 

the .js extension may not getting picked managed modules routing.

addendum: additional data within configuration section , required make work:

<configuration>   ...   <system.webserver>     <modules runallmanagedmodulesforallrequests="true">       <add name="urlroutingmodule"          type="system.web.routing.urlroutingmodule,                 system.web.routing, version=3.5.0.0,                 culture=neutral,                 publickeytoken=31bf3856ad364e35" />     </modules>     <handlers>       <add name="urlroutinghandler"         precondition="integratedmode"         verb="*" path="urlrouting.axd"         type="system.web.httpforbiddenhandler,                system.web, version=2.0.0.0, culture=neutral,                publickeytoken=b03f5f7f11d50a3a" />     </handlers>     ...   </system.webserver> </configuration> 

Popular posts from this blog