-
Notifications
You must be signed in to change notification settings - Fork 926
Making React.AspNet compatible with ASP.NET Core RC2 #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
24f78ca
aa17057
b566a5a
fa05d2e
e887678
bf07e55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
using System; | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using Microsoft.AspNet.Http; | ||
using Microsoft.AspNetCore.Http; | ||
using React.Exceptions; | ||
using React.TinyIoC; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
@@ -43,28 +43,14 @@ public HttpContextLifetimeProvider(IServiceProvider appServiceProvider) | |
/// </summary> | ||
private readonly string _keyName = PREFIX + Guid.NewGuid(); | ||
|
||
/// <summary> | ||
/// Gets the <see cref="HttpContext" /> of the current request. | ||
/// </summary> | ||
private HttpContext HttpContext => | ||
_appServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext; | ||
|
||
/// <summary> | ||
/// Gets the current per-request registrations for the current request. | ||
/// </summary> | ||
private PerRequestRegistrations Registrations | ||
{ | ||
get | ||
{ | ||
var requestServices = HttpContext.RequestServices; | ||
if (requestServices == null) | ||
{ | ||
throw new ReactNotInitialisedException( | ||
"ASP.NET request services have not been initialised correctly. Please " + | ||
"ensure you are calling app.UseRequestServices() before app.UseReact()." | ||
); | ||
} | ||
var registrations = requestServices.GetService<PerRequestRegistrations>(); | ||
var registrations = _appServiceProvider.GetService<PerRequestRegistrations>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was incorrect, it wasn't handling per-request singletons properly and was instead just using a single instance for the entire app. I fixed it in a4992da 👍 |
||
if (registrations == null) | ||
{ | ||
throw new ReactNotInitialisedException( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,51 @@ | ||
{ | ||
"version": "2.3.0-*", | ||
"configurations": { | ||
"Debug": { | ||
"compilationOptions": { | ||
"define": [ "DEBUG", "TRACE", "ASPNET5" ] | ||
} | ||
}, | ||
"Release": { | ||
"compilationOptions": { | ||
"define": [ "RELEASE", "TRACE", "ASPNET5" ], | ||
"optimize": true, | ||
"warningsAsErrors": true | ||
} | ||
} | ||
"version": "2.3.0-*", | ||
"authors": [ "Daniel Lo Nigro" ], | ||
"copyright": "Copyright 2014-Present Facebook, Inc", | ||
"title": "ReactJS.NET (MVC Core)", | ||
"description": "ReactJS and Babel tools for ASP.NET Core, including ASP.NET MVC Core. Please refer to project site (http://reactjs.net/) for full installation instructions, usage examples and sample code", | ||
"packOptions": { | ||
"owners": [ "Daniel Lo Nigro" ], | ||
"licenseUrl": "https://github.com/reactjs/React.NET#licence", | ||
"iconUrl": "http://facebook.github.io/react/img/logo_og.png", | ||
"tags": [ "asp.net", "mvc", "asp", "javascript", "js", "react", "facebook", "reactjs", "vnext" ], | ||
"projectUrl": "http://reactjs.net/" | ||
}, | ||
"configurations": { | ||
"Debug": { | ||
"buildOptions": { | ||
"define": [ "DEBUG", "TRACE", "ASPNETCORE" ] | ||
} | ||
}, | ||
"Release": { | ||
"buildOptions": { | ||
"define": [ "RELEASE", "TRACE", "ASPNETCORE" ], | ||
"optimize": true, | ||
"warningsAsErrors": true | ||
} | ||
} | ||
}, | ||
"dependencies": { | ||
"JsPool": "0.4.1", | ||
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final", | ||
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", | ||
"Microsoft.AspNet.FileProviders.Physical": "1.0.0-rc1-final", | ||
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final", | ||
"React.Core": "2.3.0-*", | ||
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final", | ||
"Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc2-final", | ||
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final", | ||
"Microsoft.Extensions.FileProviders.Physical": "1.0.0-rc2-final", | ||
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-final", | ||
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-final", | ||
"JavaScriptEngineSwitcher.Core": "1.5.0", | ||
"JavaScriptEngineSwitcher.Msie": "1.5.0", | ||
"JavaScriptEngineSwitcher.V8": "1.5.2", | ||
"MsieJavaScriptEngine": "1.7.0" | ||
"MsieJavaScriptEngine": "1.7.0", | ||
"React.Core": { | ||
"target": "project" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh cool, I didn't know about being able to target projects like this! Is there documentation on it? |
||
} | ||
}, | ||
"frameworks": { | ||
"dnx451": { } | ||
}, | ||
|
||
"authors": [ "Daniel Lo Nigro" ], | ||
"owners": [ "Daniel Lo Nigro" ], | ||
"licenseUrl": "https://github.com/reactjs/React.NET#licence", | ||
"iconUrl": "http://facebook.github.io/react/img/logo_og.png", | ||
"copyright": "Copyright 2014-Present Facebook, Inc", | ||
"title": "ReactJS.NET (MVC 6)", | ||
"description": "ReactJS and Babel tools for ASP.NET 5, including ASP.NET MVC 6. Please refer to project site (http://reactjs.net/) for full installation instructions, usage examples and sample code", | ||
"tags": [ "asp.net", "mvc", "asp", "javascript", "js", "react", "facebook", "reactjs", "vnext" ], | ||
"projectUrl": "http://reactjs.net/" | ||
"frameworks": { | ||
"net451": { | ||
"bin": { | ||
"assembly": "../../bin/React.AspNet/bin/{configuration}/net451/React.AspNet.dll", | ||
"pdb": "../../bin/React.AspNet/bin/{configuration}/net451/React.AspNet.pdb" | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this run the equivalent
dotnet
command to ensure RC2 is installed on the build machine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know it no longer works that way in RC2. There is no equivalent to dnvm in the new toolset. If you have .NET Core RC2 installed already, you can just get the ASP.NET Core packages using NuGet.
That was one of the biggest changes from RC1 to RC2, and it was done in order to make all .NET Core environments consistent with each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like they've got an install script for CI servers (see https://dotnet.github.io/docs/core-concepts/dnx-migration.html). However, their docs for AppVeyor just say "TODO" (https://dotnet.github.io/docs/core-concepts/core-sdk/cli/using-ci-with-cli.html). It's fine to ignore that for now if the AppVeyor build actually works with no changes.