Skip to content

Commit 1c1f9d5

Browse files
Update Program.cs
1 parent f38159a commit 1c1f9d5

File tree

1 file changed

+20
-20
lines changed
  • CustomAdaptor_EJ2Core/CustomAdaptor_EJ2Core

1 file changed

+20
-20
lines changed

CustomAdaptor_EJ2Core/CustomAdaptor_EJ2Core/Program.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22
using Microsoft.AspNetCore.OData;
33
using Microsoft.OData.ModelBuilder;
44
var builder = WebApplication.CreateBuilder(args);
5-
//var modelBuilder = new ODataConventionModelBuilder();
6-
//modelBuilder.EntitySet<OrdersDetails>("Orders");
5+
var modelBuilder = new ODataConventionModelBuilder();
6+
modelBuilder.EntitySet<OrdersDetails>("Orders");
77
// Add services to the container.
88
builder.Services.AddRazorPages();
99
builder.Services.AddControllers();
10-
//builder.Services.AddControllers().AddOData(
11-
// options => options
12-
// .Count()
13-
// .Filter()
14-
// .OrderBy()
15-
// .Expand()
16-
// .SetMaxTop(null)
17-
// .AddRouteComponents("odata", modelBuilder.GetEdmModel()));
18-
//builder.Services.AddCors(options =>
19-
//{
20-
// options.AddPolicy("AllowAllHeaders",
21-
// builder => builder
22-
// .WithOrigins("https://localhost:7123") // Allow frontend URL
23-
// .AllowAnyMethod()
24-
// .AllowAnyHeader()
25-
// .SetIsOriginAllowed(origin => true) // Allow all origins if needed
26-
// .AllowCredentials()); // If using authentication
27-
//});
10+
builder.Services.AddControllers().AddOData(
11+
options => options
12+
.Count()
13+
.Filter()
14+
.OrderBy()
15+
.Expand()
16+
.SetMaxTop(null)
17+
.AddRouteComponents("odata", modelBuilder.GetEdmModel()));
18+
builder.Services.AddCors(options =>
19+
{
20+
options.AddPolicy("AllowAllHeaders",
21+
builder => builder
22+
.WithOrigins("https://localhost:7123") // Allow frontend URL
23+
.AllowAnyMethod()
24+
.AllowAnyHeader()
25+
.SetIsOriginAllowed(origin => true) // Allow all origins if needed
26+
.AllowCredentials()); // If using authentication
27+
});
2828
var app = builder.Build();
2929

3030
// Configure the HTTP request pipeline.

0 commit comments

Comments
 (0)