브라우저에서 get api 결과를 보는 방법을 모르겠습니다.webapi 결과를 얻을 수 없습니다.
<Error>
<Message>
No HTTP resource was found that matches the request
URI 'http://localhost:8269/api/getProducts'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'getProducts'.
</MessageDetail>
</Error>
public class ProductsController : ApiController
{
Product[] products = new Product[]
{
new Product { ProductId=1,ProductName="samsung",ProductCategory="mobile",ProductPrice=7889 },
new Product { ProductId=1,ProductName="nokia",ProductCategory="mobile",ProductPrice=7844 },
new Product { ProductId=1,ProductName="lg",ProductCategory="mobile",ProductPrice=7887 },
new Product { ProductId=1,ProductName="xiomi",ProductCategory="mobile",ProductPrice=7856 },
new Product { ProductId=1,ProductName="htc",ProductCategory="mobile",ProductPrice=7833 }
};
public IEnumerable getProducts()
{
return products;
}
}
시도 했습니까 - http : // localhost : 8269/api/products/getproducts? – Manoj
네, 오류가 발생했습니다 ('ObjectContent'1'유형이 'application/xml; charset = utf-8'콘텐츠 유형에 대한 응답 본문을 직렬화하지 못했습니다.) – Swapna
ajax 메소드를 편집하십시오. 'ContentType : 응용 프로그램/xml' 아약스 요청? – Manoj