1
Hey, guys, all right?
I am developing my first application in web api
asp.net
.
And I’m having trouble displaying the content on a view
.
Controller:
public class ListaPresenteController : ApiController
{
public IHttpActionResult Get()
{
var produto = new Produtos();
return Ok(produto.Listar());
}
}
With this code it is working, but I could only display the list of products on home
, I’m having trouble setting up the view
of products, and I want to display the list of products for example in the url: www.meupai.com/produtos.
I believe that the idea of Web API is not well understood. Web API does not assume that the generated result will be a View, necessarily. The result is usually a JSON, interpreted by the calling page, which may or may not display a View for this.
– Leonel Sanches da Silva
Um, it may be @Ciganomorrisonmendez but here comes my question, how could I create a view, where its url is www.meuapi.com/products and I can display and manipulate (for example on a grid) the JSON’s decoration?
– Erico Souza
You can implement a static HTML and call the Web API methods using JSON, which is what the Web API tutorials suggest: http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
– Leonel Sanches da Silva