1
我試圖在PluralSight.com上關注John Papa的SPA課程,並遇到這個奇怪的問題。爲什麼我的[ActionName]屬性不起作用?
public class LookupController : ApiControllerBase
{
// GET: api/lookup/samples
[ActionName("samples")]
public IEnumerable<Sample> GetSamples()
{
return Uow.Samples.GetAll().OrderBy(x => x.Name);
}
}
如果我使用localhost:49210/api/lookup/getsamples
,我會得到一個樣品列表。但是,當我使用localhost:49210/api/lookup/samples
時,出現以下錯誤:
{"message":"No HTTP resource was found that matches the request URI
'http://localhost:49210/api/lookup/samples'.","messageDetail":"No
action was found on the controller 'Lookup' that matches the name
'samples'."}
爲什麼?