Changement pour appeler l'API C# par Angular
+ récupération des datas et leur affichage
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
|
||||
using AutoMapper;
|
||||
|
||||
using skydiveLogs_api.Business.Interface;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using AutoMapper;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
@@ -24,6 +24,7 @@ namespace skydiveLogs_api.Controllers
|
||||
|
||||
// GET: api/DropZone
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<DropZoneResp> Get()
|
||||
{
|
||||
var result = _dropZoneService.GetAllDzs();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:51376",
|
||||
"sslPort": 44344
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
@@ -21,10 +21,10 @@
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/values",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,24 @@ namespace skydiveLogs_api
|
||||
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.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
|
||||
// CORS
|
||||
services.AddCors(options =>
|
||||
{
|
||||
//options.AddPolicy(MyAllowSpecificOrigins,
|
||||
options.AddDefaultPolicy(
|
||||
builder =>
|
||||
{
|
||||
builder.WithOrigins("http://localhost:4200")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
|
||||
// IoC
|
||||
var iocService = new IocService(services);
|
||||
iocService.Configure();
|
||||
@@ -44,8 +55,14 @@ namespace skydiveLogs_api
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseCors(); // (MyAllowSpecificOrigins);
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
readonly string MyAllowSpecificOrigins = "_allowSpecificOrigins";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user