一个真正的头巾这个.我已经创建了两个ApiController,我正在使用
JSON Webservice:
namespace ControlTower.Controllers { public class AirlinesController : ApiController { private static IEnumerable<Airline> MapAirlines() { return (Jetstream.AirlineObject.GetAirlines()).Select(x => x); } [HttpGet] public IEnumerable<Airline> GetAirlines() { return MapAirlines().AsEnumerable(); } [HttpGet] public Airline GetAirlineByCode(string code) { return Jetstream.AirlineObject.GetAirline(code); } } }
和:-
namespace ControlTower.Controllers { public class ReviewsController : ApiController { private static IEnumerable<Review> MapReviews(int airline) { return (Jetstream.ReviewObject.GetReviews(airline)).Select(x => x); } [HttpGet] public IEnumerable<Review> GetReviews(int airline) { return MapReviews(airline).AsEnumerable(); } [HttpGet] public Review GetReviewById(int review) { return Jetstream.ReviewObject.GetReview(review); } } }
使用此路由: –
config.Routes.MapHttpRoute( name: "DefaultApi",routeTemplate: "api/{controller}/get/{code}",defaults: new { code = RouteParameter.Optional } );
而访问/ api /航空公司/ get / ba或/ api /航空公司/获取/工作完美,访问任何评论的变化不.任何人都可以看到我在这里错过的东西吗?
帮助是赞赏