ASP Web API "The requested resource does not support http method GET"

时间:2016-07-11 21:40:05

标签: c# asp.net asp.net-web-api

I'm new to ASP.net and Web API, so right now I have a functioning webservice and I'm trying to register a new GET route, here is my code that's based on other codes already there

[ActionName("GetReserveAvailableHours")]
        [HttpGet]
        public IEnumerable<sp_getReserveAvailableHoursResult> GetReserveAvailableHours(int AAbranch_gkey, int AAarea_gkey, DateTime AAfecha, int AAcantidad, Char AAtipo_reserva)
        {
            IEnumerable<sp_getReserveAvailableHoursResult> result;
            try
            {
                DtContex = new DTPPublicDataContext();
                /*XElement wresulFactList = new XElement("Root",
                    int. ? null : new XAttribute("branch_gkey", AAbranch_gkey),
                    String.IsNullOrEmpty(zcitygkey) ? null : new XAttribute("city_gkey", zcitygkey)
             );*/

                result = DtContex.sp_getReserveAvailableHours(AAbranch_gkey, AAarea_gkey, AAfecha, AAcantidad, AAtipo_reserva);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return result;
        }

On routes

config.Routes.MapHttpRoute(
 name: "GetReserveAvailableHours",
 routeTemplate: "api/apservice/GetReserveAvailableHours/{AAbranch_gkey}/{AAarea_gkey}/{AAfecha}/{AAcantidad}/{AAtipo}",
 defaults: new
 {
    wplace_gkey = RouteParameter.Optional


}
 );

On other questions they indicate that some code fragments are missing, but right now I don't find anything missing in comparison with other GET functions, I indicate HttpGet first. Could anyone point me out the error?

0 个答案:

没有答案