2015-02-05 38 views
0

考慮以下幾點:有什麼不對的路線

namespace Foo.Controllers 
{ 
    [RoutePrefix("api/route")] 
    public class SnoconesFooBarController : BaseApiController 
    { 
     /// <summary> 
     /// Asks for a new foo to be created to the given subnet with the specific bar named 
     /// </summary> 
     /// <param name="fooName"></param> 
     /// <param name="uriString"></param> 
     /// <returns></returns> 
     [Route("newFoo/{fooName}")] 
     public async Task<IHttpActionResult> PostNewFooForSpecificBar(string fooName, string uriString) 
     { 
     } 
} 

爲什麼我收到了404當我嘗試發佈到:

http://localhost:4471/api/route/newFoo/test1

具有以下有效載荷:

http://127.0.0.1

+0

數據的這是什麼框架(API/MVC等)的路線.. – 2015-02-05 18:23:43

+0

MVC,我改變了問題更精緻@ErikPhilips – 2015-02-05 18:26:43

+0

它是否重要,你的變量名是'sourceName'而不是'fooName'? – 2015-02-05 18:32:56

回答

0

FWIW,我通過改變它來修復它看起來是這樣的:

namespace Foo.Controllers 
{ 
    [RoutePrefix("api/route")] 
    public class SnoconesFooBarController : BaseApiController 
    { 
     /// <summary> 
     /// Asks for a new foo to be created to the given subnet with the specific bar named 
     /// </summary> 
     /// <param name="fooData"></param> 
     /// <returns></returns> 
     [Route("newFoo/")] 
     public async Task<IHttpActionResult> PostNewFooForSpecificBar(FooRequestObject fooData) 
     { 
     } 
} 

而且包括所有我需要在FooRequestObject