Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CleanArchitecture
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CleanArchitecture
Commits
ad83abb5
Commit
ad83abb5
authored
Jun 01, 2018
by
Scott DePouw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Program.cs and Startup.cs to match ASP.NET Core 2.1 templates.
parent
5ae0332d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
Program.cs
src/CleanArchitecture.Web/Program.cs
+5
-6
Startup.cs
src/CleanArchitecture.Web/Startup.cs
+17
-5
No files found.
src/CleanArchitecture.Web/Program.cs
View file @
ad83abb5
using
Microsoft.AspNetCore
.Hosting
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore
.Hosting
;
namespace
CleanArchitecture.Web
namespace
CleanArchitecture.Web
{
{
...
@@ -7,12 +7,11 @@ namespace CleanArchitecture.Web
...
@@ -7,12 +7,11 @@ namespace CleanArchitecture.Web
{
{
public
static
void
Main
(
string
[]
args
)
public
static
void
Main
(
string
[]
args
)
{
{
BuildWebHost
(
args
).
Run
();
CreateWebHostBuilder
(
args
).
Build
(
).
Run
();
}
}
public
static
IWebHost
BuildWebHost
(
string
[]
args
)
=>
public
static
IWebHost
Builder
CreateWebHostBuilder
(
string
[]
args
)
=>
WebHost
.
CreateDefaultBuilder
(
args
)
WebHost
.
CreateDefaultBuilder
(
args
)
.
UseStartup
<
Startup
>()
.
UseStartup
<
Startup
>();
.
Build
();
}
}
}
}
src/CleanArchitecture.Web/Startup.cs
View file @
ad83abb5
using
System
;
using
CleanArchitecture.Core.Interfaces
;
using
CleanArchitecture.Core.Interfaces
;
using
CleanArchitecture.Core.SharedKernel
;
using
CleanArchitecture.Core.SharedKernel
;
using
CleanArchitecture.Infrastructure.Data
;
using
CleanArchitecture.Infrastructure.Data
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
StructureMap
;
using
StructureMap
;
using
Swashbuckle.AspNetCore.Swagger
;
using
Swashbuckle.AspNetCore.Swagger
;
using
System
;
namespace
CleanArchitecture.Web
namespace
CleanArchitecture.Web
{
{
...
@@ -24,6 +26,12 @@ namespace CleanArchitecture.Web
...
@@ -24,6 +26,12 @@ namespace CleanArchitecture.Web
public
IServiceProvider
ConfigureServices
(
IServiceCollection
services
)
public
IServiceProvider
ConfigureServices
(
IServiceCollection
services
)
{
{
services
.
Configure
<
CookiePolicyOptions
>(
options
=>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options
.
CheckConsentNeeded
=
context
=>
true
;
options
.
MinimumSameSitePolicy
=
SameSiteMode
.
None
;
});
// TODO: Add DbContext and IOC
// TODO: Add DbContext and IOC
string
dbName
=
Guid
.
NewGuid
().
ToString
();
string
dbName
=
Guid
.
NewGuid
().
ToString
();
services
.
AddDbContext
<
AppDbContext
>(
options
=>
services
.
AddDbContext
<
AppDbContext
>(
options
=>
...
@@ -31,7 +39,8 @@ namespace CleanArchitecture.Web
...
@@ -31,7 +39,8 @@ namespace CleanArchitecture.Web
//options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
//options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services
.
AddMvc
()
services
.
AddMvc
()
.
AddControllersAsServices
();
.
AddControllersAsServices
()
.
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_2_1
);
services
.
AddSwaggerGen
(
c
=>
services
.
AddSwaggerGen
(
c
=>
{
{
...
@@ -50,7 +59,7 @@ namespace CleanArchitecture.Web
...
@@ -50,7 +59,7 @@ namespace CleanArchitecture.Web
_
.
WithDefaultConventions
();
_
.
WithDefaultConventions
();
_
.
ConnectImplementationsToTypesClosing
(
typeof
(
IHandle
<>));
_
.
ConnectImplementationsToTypesClosing
(
typeof
(
IHandle
<>));
});
});
// TODO: Add Registry Classes to eliminate reference to Infrastructure
// TODO: Add Registry Classes to eliminate reference to Infrastructure
// TODO: Move to Infrastucture Registry
// TODO: Move to Infrastucture Registry
...
@@ -80,14 +89,17 @@ namespace CleanArchitecture.Web
...
@@ -80,14 +89,17 @@ namespace CleanArchitecture.Web
if
(
env
.
IsDevelopment
())
if
(
env
.
IsDevelopment
())
{
{
app
.
UseDeveloperExceptionPage
();
app
.
UseDeveloperExceptionPage
();
app
.
UseBrowserLink
();
// app.UseBrowserLink(); // Must install the Microsoft.VisualStudio.Web.BrowserLink package manually for BrowserLink functionality in 2.1.
}
}
else
else
{
{
app
.
UseExceptionHandler
(
"/Home/Error"
);
app
.
UseExceptionHandler
(
"/Home/Error"
);
app
.
UseHsts
();
}
}
app
.
UseHttpsRedirection
();
app
.
UseStaticFiles
();
app
.
UseStaticFiles
();
app
.
UseCookiePolicy
();
// Enable middleware to serve generated Swagger as a JSON endpoint.
// Enable middleware to serve generated Swagger as a JSON endpoint.
app
.
UseSwagger
();
app
.
UseSwagger
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment