|
1 | | -using Microsoft.AspNet.Builder; |
2 | | -using Microsoft.AspNet.Hosting; |
3 | | -using Microsoft.AspNet.SpaServices; |
4 | | -using Microsoft.Extensions.Configuration; |
5 | | -using Microsoft.Extensions.DependencyInjection; |
6 | | -using Microsoft.Extensions.Logging; |
7 | | -using Microsoft.Extensions.PlatformAbstractions; |
8 | | - |
9 | | -namespace ReactExample |
10 | | -{ |
11 | | - public class Startup |
12 | | - { |
13 | | - public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) |
14 | | - { |
15 | | - // Setup configuration sources. |
16 | | - var builder = new ConfigurationBuilder() |
17 | | - .SetBasePath(appEnv.ApplicationBasePath) |
18 | | - .AddJsonFile("appsettings.json") |
19 | | - .AddEnvironmentVariables(); |
20 | | - Configuration = builder.Build(); |
21 | | - } |
22 | | - |
23 | | - public IConfigurationRoot Configuration { get; set; } |
24 | | - |
25 | | - // This method gets called by the runtime. |
26 | | - public void ConfigureServices(IServiceCollection services) |
27 | | - { |
28 | | - // Add MVC services to the services container. |
29 | | - services.AddMvc(); |
30 | | - } |
31 | | - |
32 | | - // Configure is called after ConfigureServices is called. |
33 | | - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
34 | | - { |
35 | | - loggerFactory.MinimumLevel = LogLevel.Warning; |
36 | | - loggerFactory.AddConsole(); |
37 | | - loggerFactory.AddDebug(); |
38 | | - |
39 | | - // Configure the HTTP request pipeline. |
40 | | - |
41 | | - // Add the platform handler to the request pipeline. |
42 | | - app.UseIISPlatformHandler(); |
43 | | - |
44 | | - // Add the following to the request pipeline only in development environment. |
45 | | - if (env.IsDevelopment()) |
46 | | - { |
47 | | - app.UseDeveloperExceptionPage(); |
48 | | - } |
49 | | - else |
50 | | - { |
51 | | - // Add Error handling middleware which catches all application specific errors and |
52 | | - // send the request to the following path or controller action. |
53 | | - app.UseExceptionHandler("/Home/Error"); |
54 | | - } |
55 | | - |
56 | | - // In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement. |
57 | | - // In production, we assume you've used webpack to emit the prebuilt content to disk. |
58 | | - if (env.IsDevelopment()) { |
59 | | - app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { |
60 | | - HotModuleReplacement = true, |
61 | | - ReactHotModuleReplacement = true |
62 | | - }); |
63 | | - } |
64 | | - |
65 | | - // Add static files to the request pipeline. |
66 | | - app.UseStaticFiles(); |
67 | | - |
68 | | - // Add MVC to the request pipeline. |
69 | | - app.UseMvc(routes => |
70 | | - { |
71 | | - routes.MapSpaFallbackRoute( |
72 | | - name: "default", |
73 | | - defaults: new { controller="Home", action = "Index" }); |
74 | | - }); |
75 | | - } |
76 | | - } |
77 | | -} |
| 1 | +using Microsoft.AspNet.Builder; |
| 2 | +using Microsoft.AspNet.Hosting; |
| 3 | +using Microsoft.AspNet.SpaServices.Webpack; |
| 4 | +using Microsoft.Extensions.Configuration; |
| 5 | +using Microsoft.Extensions.DependencyInjection; |
| 6 | +using Microsoft.Extensions.Logging; |
| 7 | +using Microsoft.Extensions.PlatformAbstractions; |
| 8 | + |
| 9 | +namespace ReactExample |
| 10 | +{ |
| 11 | + public class Startup |
| 12 | + { |
| 13 | + public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) |
| 14 | + { |
| 15 | + // Setup configuration sources. |
| 16 | + var builder = new ConfigurationBuilder() |
| 17 | + .SetBasePath(appEnv.ApplicationBasePath) |
| 18 | + .AddJsonFile("appsettings.json") |
| 19 | + .AddEnvironmentVariables(); |
| 20 | + Configuration = builder.Build(); |
| 21 | + } |
| 22 | + |
| 23 | + public IConfigurationRoot Configuration { get; set; } |
| 24 | + |
| 25 | + // This method gets called by the runtime. |
| 26 | + public void ConfigureServices(IServiceCollection services) |
| 27 | + { |
| 28 | + // Add MVC services to the services container. |
| 29 | + services.AddMvc(); |
| 30 | + } |
| 31 | + |
| 32 | + // Configure is called after ConfigureServices is called. |
| 33 | + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
| 34 | + { |
| 35 | + loggerFactory.MinimumLevel = LogLevel.Warning; |
| 36 | + loggerFactory.AddConsole(); |
| 37 | + loggerFactory.AddDebug(); |
| 38 | + |
| 39 | + // Configure the HTTP request pipeline. |
| 40 | + |
| 41 | + // Add the platform handler to the request pipeline. |
| 42 | + app.UseIISPlatformHandler(); |
| 43 | + |
| 44 | + // Add the following to the request pipeline only in development environment. |
| 45 | + if (env.IsDevelopment()) |
| 46 | + { |
| 47 | + app.UseDeveloperExceptionPage(); |
| 48 | + } |
| 49 | + else |
| 50 | + { |
| 51 | + // Add Error handling middleware which catches all application specific errors and |
| 52 | + // send the request to the following path or controller action. |
| 53 | + app.UseExceptionHandler("/Home/Error"); |
| 54 | + } |
| 55 | + |
| 56 | + // In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement. |
| 57 | + // In production, we assume you've used webpack to emit the prebuilt content to disk. |
| 58 | + if (env.IsDevelopment()) { |
| 59 | + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { |
| 60 | + HotModuleReplacement = true, |
| 61 | + ReactHotModuleReplacement = true |
| 62 | + }); |
| 63 | + } |
| 64 | + |
| 65 | + // Add static files to the request pipeline. |
| 66 | + app.UseStaticFiles(); |
| 67 | + |
| 68 | + // Add MVC to the request pipeline. |
| 69 | + app.UseMvc(routes => |
| 70 | + { |
| 71 | + routes.MapSpaFallbackRoute( |
| 72 | + name: "default", |
| 73 | + defaults: new { controller="Home", action = "Index" }); |
| 74 | + }); |
| 75 | + } |
| 76 | + } |
| 77 | +} |
0 commit comments