FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Maxula-project/Program.cs at main · Ashref-dev/Maxula-project · GitHub
Ashref-dev
/
Maxula-project
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
6
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Maxula-project
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
122 lines (90 loc) · 3.2 KB
Breadcrumbs
Maxula-project
/
Program.cs
Copy path
File metadata and controls
122 lines (90 loc) · 3.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using
Microsoft
.
EntityFrameworkCore
;
using
Maxula_project
.
Components
;
using
Maxula_project
.
Services
.
ActivityService
;
using
Maxula_project
.
Services
.
UserService
;
using
Maxula_project
.
Utils
.
ConsoleLogger
;
using
Syncfusion
.
Blazor
;
using
BlazorDownloadFile
;
using
Maxula_project
.
Services
.
EmailService
;
var
builder
=
WebApplication
.
CreateBuilder
(
args
)
;
// Configure app settings based on environment prep
var
env
=
builder
.
Environment
;
// Add services to the container.
builder
.
Services
.
AddRazorComponents
(
)
.
AddInteractiveServerComponents
(
)
;
builder
.
Services
.
AddControllers
(
)
;
if
(
env
.
IsProduction
(
)
)
{
builder
.
Services
.
AddCors
(
options
=>
{
options
.
AddPolicy
(
"AllowSpecificOrigin"
,
corsPolicyBuilder
=>
{
corsPolicyBuilder
.
WithOrigins
(
"https://maxula.azurewebsites.net/"
)
.
AllowAnyHeader
(
)
.
AllowAnyMethod
(
)
;
}
)
;
}
)
;
}
else
{
builder
.
Services
.
AddCors
(
options
=>
{
options
.
AddDefaultPolicy
(
corsPolicyBuilder
=>
{
corsPolicyBuilder
.
AllowAnyOrigin
(
)
.
AllowAnyHeader
(
)
.
AllowAnyMethod
(
)
;
}
)
;
}
)
;
}
// read this
// https://learn.microsoft.com/en-us/ef/core/dbcontext-configuration/
builder
.
Services
.
AddDbContextFactory
<
DataContext
>
(
(
options
)
=>
{
string
connectionString
;
if
(
env
.
IsProduction
(
)
)
{
connectionString
=
builder
.
Configuration
.
GetConnectionString
(
"NeonConnection"
)
;
}
else
{
connectionString
=
builder
.
Configuration
.
GetConnectionString
(
"DefaultConnection"
)
;
}
options
.
UseNpgsql
(
connectionString
)
;
}
)
;
builder
.
Services
.
AddQuickGridEntityFrameworkAdapter
(
)
;
// adding custom js console log for browser console
builder
.
Services
.
AddScoped
<
IConsoleLoggerService
,
ConsoleLoggerService
>
(
)
;
// adding mapper then services
builder
.
Services
.
AddAutoMapper
(
typeof
(
Program
)
.
Assembly
)
;
builder
.
Services
.
AddScoped
<
IActivityService
,
ActivityService
>
(
)
;
builder
.
Services
.
AddScoped
<
IUserService
,
UserService
>
(
)
;
builder
.
Services
.
AddScoped
<
IEmailService
,
EmailService
>
(
)
;
builder
.
Services
.
AddSingleton
<
DateService
>
(
)
;
builder
.
Services
.
AddSyncfusionBlazor
(
)
;
builder
.
Services
.
AddBlazorDownloadFile
(
)
;
var
app
=
builder
.
Build
(
)
;
Syncfusion
.
Licensing
.
SyncfusionLicenseProvider
.
RegisterLicense
(
builder
.
Configuration
[
"SYNCFUSION_LICENSE_KEY"
]
)
;
// Configure the HTTP request pipeline.
if
(
!
app
.
Environment
.
IsDevelopment
(
)
)
{
app
.
UseExceptionHandler
(
"/Error"
,
createScopeForErrors
:
true
)
;
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app
.
UseHsts
(
)
;
}
// redirect bad routes to a 404 page
app
.
UseStatusCodePagesWithRedirects
(
"/404"
)
;
app
.
UseHttpsRedirection
(
)
;
app
.
UseStaticFiles
(
)
;
// Add this line for routing asp net ( the places are important, routing then anti forgery then controllers endpoints)
app
.
UseRouting
(
)
;
// Use CORS policy in the HTTP request pipeline, the order matters os google it xD
app
.
UseCors
(
)
;
app
.
UseAntiforgery
(
)
;
// Ensure that your API controllers are routed correctly
app
.
MapControllers
(
)
;
app
.
MapRazorComponents
<
App
>
(
)
.
AddInteractiveServerRenderMode
(
)
;
app
.
Run
(
)
;
Back
|
FazBrowse Home
|
New Git URL