Skip to content

Commit 1f7ec8e

Browse files
Update ReactGrid example to RC2
1 parent 649c607 commit 1f7ec8e

File tree

6 files changed

+74
-72
lines changed

6 files changed

+74
-72
lines changed

samples/react/ReactGrid/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.AspNet.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
22

33
namespace ReactExample.Controllers
44
{

samples/react/ReactGrid/Controllers/PeopleApiController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22
using System.Threading.Tasks;
3-
using Microsoft.AspNet.Mvc;
3+
using Microsoft.AspNetCore.Mvc;
44

55
namespace ReactExample.Controllers
66
{
@@ -10,9 +10,9 @@ public class PeopleApiController : Controller
1010
public ActionResult UpdatePerson([FromBody] PersonDto person)
1111
{
1212
if (!ModelState.IsValid) {
13-
return HttpBadRequest(ModelState);
13+
return BadRequest(ModelState);
1414
} else {
15-
return new HttpOkResult();
15+
return new OkResult();
1616
}
1717
}
1818
}

samples/react/ReactGrid/Startup.cs

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,66 @@
1-
using Microsoft.AspNet.Builder;
2-
using Microsoft.AspNet.Hosting;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.AspNetCore.Http;
39
using Microsoft.AspNet.SpaServices.Webpack;
4-
using Microsoft.Extensions.Configuration;
510
using Microsoft.Extensions.DependencyInjection;
611
using Microsoft.Extensions.Logging;
7-
using Microsoft.Extensions.PlatformAbstractions;
12+
using Newtonsoft.Json.Serialization;
813

9-
namespace ReactExample
14+
namespace ReactGrid
1015
{
1116
public class Startup
1217
{
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.
18+
// This method gets called by the runtime. Use this method to add services to the container.
2619
public void ConfigureServices(IServiceCollection services)
2720
{
28-
// Add MVC services to the services container.
29-
services.AddMvc();
21+
services.AddMvc().AddJsonOptions(options =>
22+
{
23+
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
24+
});
3025
}
3126

32-
// Configure is called after ConfigureServices is called.
33-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
27+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
28+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
3429
{
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();
30+
app.UseDeveloperExceptionPage();
4331

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.
5832
if (env.IsDevelopment()) {
5933
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
6034
HotModuleReplacement = true,
6135
ReactHotModuleReplacement = true
6236
});
6337
}
6438

65-
// Add static files to the request pipeline.
6639
app.UseStaticFiles();
67-
68-
// Add MVC to the request pipeline.
40+
loggerFactory.AddConsole();
6941
app.UseMvc(routes =>
7042
{
71-
routes.MapSpaFallbackRoute(
43+
routes.MapRoute(
7244
name: "default",
73-
defaults: new { controller="Home", action = "Index" });
45+
template: "{controller=Home}/{action=Index}/{id?}");
46+
47+
routes.MapSpaFallbackRoute(
48+
name: "spa-fallback",
49+
defaults: new { controller = "Home", action = "Index" });
7450
});
7551
}
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+
}
7665
}
7766
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@using ReactExample
2-
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
2+
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
33
@addTagHelper "*, Microsoft.AspNet.SpaServices"

samples/react/ReactGrid/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"webpack-externals-plugin": "^1.0.0"
1919
},
2020
"devDependencies": {
21+
"aspnet-prerendering": "^1.0.0",
22+
"aspnet-webpack": "^1.0.3",
23+
"aspnet-webpack-react": "^1.0.1",
2124
"babel-loader": "^6.2.1",
2225
"babel-plugin-react-transform": "^2.0.0",
2326
"babel-preset-es2015": "^6.3.13",
Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,53 @@
11
{
2-
"webroot": "wwwroot",
32
"version": "1.0.0-*",
4-
"tooling": {
5-
"defaultNamespace": "ReactExample"
3+
"compilationOptions": {
4+
"emitEntryPoint": true,
5+
"warningsAsErrors": true,
6+
"preserveCompilationContext": true
67
},
78
"dependencies": {
8-
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-*",
9-
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-*",
10-
"Microsoft.AspNet.Mvc": "6.0.0-rc1-*",
11-
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-*",
12-
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-*",
13-
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-*",
14-
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-*",
15-
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-*",
16-
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-*",
9+
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
10+
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
11+
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
12+
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
13+
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
14+
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
15+
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
16+
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
17+
"Microsoft.NETCore.Platforms": "1.0.1-*",
18+
"Microsoft.Extensions.Logging.Debug": "1.0.0-*",
1719
"Microsoft.AspNet.ReactServices": "1.0.0-*"
1820
},
1921
"commands": {
2022
"web": "Microsoft.AspNet.Server.Kestrel"
2123
},
2224
"frameworks": {
2325
"dnx451": {},
24-
"dnxcore50": {}
26+
"netstandardapp1.5": {
27+
"imports": [
28+
"dnxcore50",
29+
"portable-net451+win8"
30+
],
31+
"dependencies": {
32+
"NETStandard.Library": "1.5.0-*"
33+
}
34+
}
2535
},
36+
2637
"exclude": [
2738
"wwwroot",
28-
"node_modules",
29-
"bower_components"
39+
"node_modules"
3040
],
3141
"publishExclude": [
3242
"node_modules",
33-
"bower_components",
3443
"**.xproj",
3544
"**.user",
3645
"**.vspscc"
3746
],
3847
"scripts": {
39-
"prepublish": [
40-
"npm install"
48+
"prepare": [
49+
"npm install",
50+
"webpack"
4151
]
4252
}
4353
}

0 commit comments

Comments
 (0)