1- using Microsoft . AspNet . Builder ;
2- using Microsoft . AspNet . Hosting ;
1+ using Microsoft . AspNetCore . Builder ;
2+ using Microsoft . AspNetCore . Hosting ;
3+ using Microsoft . AspNetCore . Http ;
34using Microsoft . AspNet . NodeServices ;
4- using Microsoft . AspNet . Http ;
5- using Microsoft . Extensions . PlatformAbstractions ;
6- using Microsoft . Extensions . Configuration ;
75using Microsoft . Extensions . DependencyInjection ;
86using Microsoft . Extensions . Logging ;
7+ using System . IO ;
98
109namespace ES2015Example
1110{
1211 public class Startup
1312 {
14- public Startup ( IHostingEnvironment env , IApplicationEnvironment appEnv )
15- {
16- // Setup configuration sources.
17- var builder = new ConfigurationBuilder ( )
18- . SetBasePath ( appEnv . ApplicationBasePath )
19- . AddJsonFile ( "appsettings.json" )
20- . AddEnvironmentVariables ( ) ;
21- Configuration = builder . Build ( ) ;
22- }
23-
24- public IConfigurationRoot Configuration { get ; set ; }
25-
26- // This method gets called by the runtime.
13+ // This method gets called by the runtime. Use this method to add services to the container.
2714 public void ConfigureServices ( IServiceCollection services )
2815 {
29- // Add MVC services to the services container.
3016 services . AddMvc ( ) ;
31-
17+
3218 // Enable Node Services
3319 services . AddNodeServices ( ) ;
3420 }
3521
36- // Configure is called after ConfigureServices is called .
37- public void Configure ( IApplicationBuilder app , IHostingEnvironment env , ILoggerFactory loggerFactory , INodeServices nodeServices )
22+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline .
23+ public void Configure ( IApplicationBuilder app , ILoggerFactory loggerFactory , IHostingEnvironment env , INodeServices nodeServices )
3824 {
39- loggerFactory . MinimumLevel = LogLevel . Warning ;
40- loggerFactory . AddConsole ( ) ;
41- loggerFactory . AddDebug ( ) ;
42-
43- // Configure the HTTP request pipeline.
44-
45- // Add the platform handler to the request pipeline.
46- app . UseIISPlatformHandler ( ) ;
47-
48- // Add the following to the request pipeline only in development environment.
49- if ( env . IsDevelopment ( ) )
50- {
51- app . UseDeveloperExceptionPage ( ) ;
52- }
53- else
54- {
55- // Add Error handling middleware which catches all application specific errors and
56- // send the request to the following path or controller action.
57- app . UseExceptionHandler ( "/Home/Error" ) ;
58- }
25+ app . UseDeveloperExceptionPage ( ) ;
5926
6027 // Dynamically transpile any .js files under the '/js/' directory
6128 app . Use ( next => async context => {
@@ -73,17 +40,27 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
7340 await next . Invoke ( context ) ;
7441 } ) ;
7542
76- // Add static files to the request pipeline.
7743 app . UseStaticFiles ( ) ;
78-
79- // Add MVC to the request pipeline.
44+ loggerFactory . AddConsole ( ) ;
8045 app . UseMvc ( routes =>
8146 {
8247 routes . MapRoute (
8348 name : "default" ,
84- template : "{controller}/{action?}/{id?}" ,
85- defaults : new { controller = "Home" , action = "Index" } ) ;
49+ template : "{controller=Home}/{action=Index}/{id?}" ) ;
8650 } ) ;
8751 }
52+
53+ public static void Main ( string [ ] args )
54+ {
55+ var host = new WebHostBuilder ( )
56+ . UseContentRoot ( Directory . GetCurrentDirectory ( ) )
57+ . UseDefaultHostingConfiguration ( args )
58+ . UseIISPlatformHandlerUrl ( )
59+ . UseKestrel ( )
60+ . UseStartup < Startup > ( )
61+ . Build ( ) ;
62+
63+ host . Run ( ) ;
64+ }
8865 }
8966}
0 commit comments