0
ASP.NET MVC처럼 간단하지만 URI의 문자열 매개 변수를 내 컨트롤러의 동작에 매핑하는 방법을 알 수 없습니다.문자열 매개 변수로 동작하는 웹 API 라우팅
GetSocieteByLibelle (캐릭터 이름)
내 경로 구성 : 그래서 조치와 함께 URI를 매핑하고 싶은
//GET: api/Societe
public IEnumerable<Societe> GetSociete()
{
List<Societe> listeSociete = Librairie.Societes.getAllSociete();
return listeSociete.ToList();
}
//GET: api/Societe/id
[ResponseType(typeof(Societe))]
public IHttpActionResult GetSociete(int id)
{
Societe societeRecherchee = Librairie.Societes.getSociete(id);
if (societeRecherchee == null)
{
return NotFound();
}
else
{
return Ok(societeRecherchee);
}
}
public IHttpActionResult GetSocieteByLibelle(string name)
{
Societe societeRecherchee = new Societe();
if (!string.IsNullOrWhiteSpace(name))
{
societeRecherchee = Librairie.Societes.getSocieteByLibelle(name);
if (societeRecherchee == null)
{
return NotFound();
}
}
return Ok(societeRecherchee);
}
: 그래서 다음과 같이 내 컨트롤러의 세 가지 작업을해야 Wep API 프로젝트의 기본 설정입니다. 어떤 사람이 URI를 해당 동작에 매핑하는 방법을 설명해 주시겠습니까? 미리 감사드립니다!