How to create subfolders for Api on Asp.net webapi?

Asked

Viewed 258 times

1

By default, the folder is Controllers

I would like to create other subfolders

Controllers -> Api -> Othern/ Other2 etc

How do I do this? and how do you configure the router for this?

1 answer

1

The only thing that came to me at the time is the creation of Area, as:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Within the Controller of Area Vow has a DadosController which is a WebApi, follows the code:

public class DadosController : ApiController
{
    // GET api/<controller>
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

    // GET api/<controller>/5
    public string Get(int id)
    {
        return "value";
    }

    // POST api/<controller>
    public void Post([FromBody]string value)
    {
    }

    // PUT api/<controller>/5
    public void Put(int id, [FromBody]string value)
    {
    }

    // DELETE api/<controller>/5
    public void Delete(int id)
    {
    }
}

Running in the same way:

inserir a descrição da imagem aqui

The route settings in this case are already done automatically when creating the Area. To use also if no different route nomenclature is elaborated is the way it is in the example file: GET api/<controller>, following the standard model.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.