ApiController
[Produces("application/json")]
[Route("api/[controller]")]
public class ClienteController : Controller
{
private IClienteRepository _ClienteRepository;
public ClienteController(IClienteRepository clienteRepository)
{
_ClienteRepository = clienteRepository;
}
[HttpPost]
public IEnumerable<Cliente> Get()
{
return _ClienteRepository.Get(x => x.ClienteId > 0);
}
}
Stratup
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IClienteRepository, ClienteRepository>();
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
}
LaunchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52676/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/cliente",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Safra.AberturaDeContas.Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/cliente",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:52677/"
}
}
}
Error uploading api by visiting link :
This localhost page can not be found