我想使用类OfferFilter来处理商品请求:
public class OfferFilter
{
public int SortOrder { get; set; }
public int PageSize { get; set; }
public int PageNumber { get; set; }
public string SearchQuery { get; set; }
public bool ShowAllLanguages { get; set; }
public int? SearcherSectorId { get; set; }
public int? CountryId { get; set; }
public int? RegionId { get; set; }
public string City { get; set; }
public int? AskingPriceFrom { get; set; }
public int? AskingPriceTo { get; set; }
public bool AskingPriceSelected { get; set; }
public int? SalesRevenuesFrom { get; set; }
public int? SalesRevenuesTo { get; set; }
public bool SalesRevenuesSelected { get; set; }
public int? IncomeFrom { get; set; }
public int? IncomeTo { get; set; }
public bool IncomeSelected { get; set; }
public int? Age { get; set; }
}
如何为此制作路线属性?使用POST会更容易,但它将是GET请求。正常的路由字符串将是巨大的并且非常容易出错。
答案 0 :(得分:1)
请参阅Routing上的Wiki页面。您只需要注册服务的路径信息,您仍然可以使用QueryString中的任何属性,例如:
[Route("/offers/search")]
public class OfferFilter { ... }
允许您使用任何组合调用上述服务,例如:
/offers/search?city=XXX
/offers/search?city=XXX&Age=20
etc.