所以,我在我的API 3種方法:MVC的Web API錯誤不會忽略方法
public List<FlatResponse> GetFlats()
public Flat Reserve(int id, int customerId, string service)
public List<FlatResponse> SearchFlats(double budget, double surface)
現在,不知何故,每個響應的API使用GetFlats()
方法。
也許我使用了錯誤的網址?
要預訂平,我用
myUrl.com/api/flats/?id=1&customerId=2&service=someservice
。 要搜索特定的單位,我用
myUrl.com/api/flats/?budget=500&surface=30
我在做什麼錯?
編輯:
這可能是我的項目是不正確的結構。雖然它在另一個API中起作用。
我Flatcontroller類
public class FlatsController : ApiController
{
public List<FlatResponse> GetFlats()
{
...
}
public Flat Reserve(int id, int customerId, string service)
{
...
}
public List<FlatResponse> SearchFlats(double budget, double surface)
{
...
}
}
的flatresponse類
public class FlatResponse
{
public int Id { get; set; }
public string Description { get; set; }
public string Street { get; set; }
public int HouseNumber { get; set; }
public int PostalCode { get; set; }
public string City { get; set; }
public double RentalPrice { get; set; }
public double Surface { get; set; }
public int ContractTime { get; set; }
public DateTime StartDate { get; set; }
public List<string> Facilities { get; set; }
public string ContactPersonName { get; set; }
public string ContactPersonEmail { get; set; }
public string ContactPersonTelephone { get; set; }
public bool Reserved { get; set; }
public string DetailUrl { get; set; }
public string ImageUrl { get; set; }
}
你的方法不是正確的控制器方法(它們不會返回任何'___ Result')。控制器方法在哪裏? – zmbq
請顯示flatsController類 – scartag
此外,是否應該有URL 1和URL 2之間的區別?你們每個人都必須有一個原因嗎? –