Posts

Showing posts with the label routing

WebAPI routing does not work

Image
Clash Royale CLAN TAG #URR8PPP WebAPI routing does not work I have WebApiConfig public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); } } Web API controller: [RoutePrefix("api/Trip")] public class TripApiController : ApiController { [Route("SaveRouting")] [HttpPost] public async Task<HttpResponseMessage> SaveRouting(string points, int tripId, decimal totalMileage) { // ...... return Request.CreateResponse(HttpStatusCode.OK); } and call from jquery: $.post("/api/trip/SaveRouting", { points: JSON.stringify(arrayStops), tripId: $("#hdTripId").val(), totalMileage: tMiles }, fu...

routing in iis 8.5 for mvc and webapi apps

Image
Clash Royale CLAN TAG #URR8PPP routing in iis 8.5 for mvc and webapi apps I am running windows 8 IIS 8.5. I created my site on IIS and created another site in a directory below for my webapi service So my site looks like this: www.mysite.com www.mysite.com/api // this exists on disk in a directory called api below the site dir. Configured in IIS as a site not a virtual dir. Of course iis is unable to implement routing for either site. ww.mysite.com works if I add /index.html. If I type www.mysite.com into browser I get a 404. The api site simply gives me 404 errors no matter what I do. Both sites work perfectly fine when running in visual studio. www.mysite.com is a mvc 5 application www.mysite.com/api is a webapi 3 application. Some questions such as this one: ASP.NET 4.5 MVC 4 not working on Windows Server 2008 IIS 7 recommend <modules runAllManagedModulesForAllRequests="true" /> which does not work and is suboptimal even if it did work. Other problems others hav...