Skip to content

Commit 266abaf

Browse files
committed
Getting started guide for ASP.NET 5
1 parent 824dc15 commit 266abaf

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

site/jekyll/_posts/2015-03-02-1.4.0-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ I'm happy to announce the release of ReactJS.NET 1.4! This release adds support
88

99
Full list of changes:
1010

11-
* [#47](https://github.com/reactjs/React.NET/issues/47) and [#94](https://github.com/reactjs/React.NET/pull/94) — Support for ASP.NET 5. You must be using Visual Studio 2015 CTP6 and ASP.NET 5 Beta 3. Documentation will be added to the site shortly.
11+
* [#47](https://github.com/reactjs/React.NET/issues/47) and [#94](https://github.com/reactjs/React.NET/pull/94)[Support for ASP.NET 5](/getting-started/aspnet5.html). You must be using Visual Studio 2015 CTP6 and ASP.NET 5 Beta 3. Documentation will be added to the site shortly.
1212
* [#86](https://github.com/reactjs/React.NET/issues/86)`console` calls such as `console.log` during server-side rendering will automatically be propagated to the client-side. This can greatly assist in debugging server-side rendering. Nicer debugging tools will come in the future!
1313
* [#96](https://github.com/reactjs/React.NET/issues/96) — Bundle V8 support by default, stop relying on MSIE engine as much.
1414
* [#97](https://github.com/reactjs/React.NET/issues/97) — Upgrade to JSPool 0.2. This improves the handling of JavaScript engines by recycling them after a number of uses, which ensures memory usage doesn't keep growing over time.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
id: aspnet5
3+
layout: docs
4+
title: Getting Started on ASP.NET 5
5+
---
6+
7+
Getting started with ReactJS.NET on ASP.NET 5 and MVC 6 requires a few more steps compared to previous versions of ASP.NET and MVC. A more fully featured tutorial will be released once the stable release of ASP.NET 5 is out.
8+
9+
Note that ASP.NET 5 is still in beta, and so there may still be some sharp edges. ReactJS.NET requires at least Visual Studio 2015 CTP6 and ASP.NET 5 Beta 3. Additionally, ReactJS.NET does not support the Core CLR at this point in time, so you will need to ensure your project is not referencing it. Remove the `"aspnetcore50": { }` line from your `project.json` file.
10+
11+
Once this has been removed, install the `React.AspNet` package through NuGet. After the package is installed, ReactJS.NET needs to be initialised in your `Startup.cs` file (unfortunately this can not be done automatically like in previous versions of ASP.NET with WebActivator). At the top of the file, add:
12+
```
13+
using React.AspNet;
14+
```
15+
16+
Directly above:
17+
18+
```csharp
19+
// Add MVC services to the services container.
20+
services.AddMvc();
21+
```
22+
23+
Add:
24+
25+
```csharp
26+
services.AddReact();
27+
```
28+
29+
30+
Directly above:
31+
32+
```csharp
33+
// Add static files to the request pipeline.
34+
app.UseStaticFiles();
35+
```
36+
37+
Add:
38+
39+
```csharp
40+
app.UseRequestServices();
41+
app.UseReact(config =>
42+
{
43+
// ES6 features are enabled by default. Uncomment the below line to disable them.
44+
// See http://reactjs.net/guides/es6.html for more information.
45+
//config.SetUseHarmony(false);
46+
// Uncomment the below line if you are using Flow
47+
// See http://reactjs.net/guides/flow.html for more information.
48+
//config.SetStripTypes(true);
49+
// If you want to use server-side rendering of React components,
50+
// add all the necessary JavaScript files here. This includes
51+
// your components as well as all of their dependencies.
52+
// See http://reactjs.net/ for more information. Example:
53+
//config
54+
// .AddScript("~/Scripts/First.jsx")
55+
// .AddScript("~/Scripts/Second.jsx");
56+
});
57+
```
58+
59+
Finally, add this to `Views/_GlobalImport.cshtml` (or create it if it doesn't exist):
60+
61+
```csharp
62+
@using React.AspNet
63+
```
64+
65+
Once ReactJS.NET has been configured, you will be able to use [on-the-fly JSX to JavaScript compilation](http://reactjs.net/getting-started/usage.html) and [server-side rendering](http://reactjs.net/guides/server-side-rendering.html).

site/jekyll/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ id: home
2020
other .NET languages, focusing specifically on ASP.NET MVC (although it
2121
also works in other environments). It assumes you already have some basic
2222
knowledge about React. It is cross-platform and can run on Linux via Mono.
23+
Now with support for [ASP.NET 5 Beta](/getting-started/aspnet5.html)!
2324
Take a look at [the tutorial](/getting-started/tutorial.html) to see how
2425
easy it is to get started with React and ReactJS.NET!
2526
</p>

0 commit comments

Comments
 (0)