-
Notifications
You must be signed in to change notification settings - Fork 932
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
Error on startup in core 2.0 'React.AspNet.HttpContextLifetimeProvider` #433
Comments
Likely a breaking change in 2.0. I haven't tested with 2.0 yet. Feel free to submit a pull request if you do work out what broke. |
I'd give it a crack but I can't seem to get it to build. dev-build.bat is completing with errors. "**/*.resx couldn't be found" is about the only intelligible output I'm seeing at the moment. |
Does it look like this?
You may be hitting this issue: https://dan.cx/2017/05/fixing-msb3552-resource-file-resx-cannot-be-found:
|
That's the one |
One of the causes I've seen of that is old npm versions. Check |
Yeah I saw that in the instructions but that didn't seem to help. Then I tried moving the repo folder all the way down to my C: drive to help shorten the paths, but windows is warning me that the filenames are still too long. |
I got it to run without any modification to the React.Net source. The problem is the way now things are initialized in Startup.cs in ASP.NET Core 2.0 The problem is that now services are not available at some points in the Startup process. To ensure that 'React.AspNet.HttpContextLifetimeProvider+PerRequestRegistrations' is available the easiest way is to change the type of Either way I'm going to make a pull request where I update the whole React.NET to ASP.NET Core 2.0. One of the biggest advantages is that now with .NET Standard 2.0 is no longer necessary to make so many divisions between .NET Framework and .NET Core libraries. |
@ShikiGami your fix works for me change and |
It may be worth noting that for obvious reasons, only had the problem on a windows machine. I had no issue starting a new project on Linux. |
@ShikiGami |
@ShikiGami, |
Hey @ShikiGami, thanks for your comment! I actually hit this same error when updating my own website, and your comment helped resolve it :) I know you have a PR updating some code in this repo, but please also feel free to open a pull request updating the documentation on the ReactJS.NET website. The documentaton page is at https://reactjs.net/getting-started/aspnetcore.html, and the contents are located in this repository. Otherwise, I'll do it, but it likely won't be for another week or two as I'm pretty busy over the next week. |
Thanks for the fix, works great now ! |
Just to add some clarity as to what is happening here. The DependencyInjection framework is by default configured to use call-site validation whenever a service is requested. When UseReact is called, it's ensuring that the required per-request services are available by using GetService from the root call-site, and this is obviously incompatible with the call-site validation feature. You can disable call-site validation in you WebHost configuration by adding: |
The samples have been updated to .NET Core 2.0, so closing this issue for now. Please feel free to re-open if you'd like some more help! |
The issue still happened in .Net Core 2.0 |
Hi there, what version of React.AspNet are you building against? The samples in this repo use .Net Core 2.0 so I’m curious why you are still getting errors. |
I'm using lastest version of .Net core 2.0 |
@ShikiGami |
@ShikiGami Thanks for the solution! |
The service should be checked within a scope because the class HttpContextLifetimeProvider.PerRequestRegistrations is registered as scoped lifetime.
Here is the code to check the service in a scope. private static void EnsureServicesRegistered(IApplicationBuilder app)
{
using (var scope = app.ApplicationServices.CreateScope())
{
var registrations = scope.ServiceProvider.GetService<HttpContextLifetimeProvider.PerRequestRegistrations>();
if (registrations == null)
{
throw new ReactNotInitialisedException("Please call services.AddReact() before app.UseReact().");
}
}
} |
Happening on VS2017 new AspNetCore MVC app with Core 2.1. |
I am trying the sample code under ReactJS.NET tutorial(https://reactjs.net/tutorials/aspnetcore.html) & despite making the changes you mentioned it doesn't work. Same works with ASP.NET Core 2.0 |
I published a beta that fixes this error, please update to the latest beta
and try again.
…On Thu, Nov 15, 2018 at 10:37, hlalit03 ***@***.***> wrote:
I am trying the sample code under ReactJS.NET tutorial(
https://reactjs.net/tutorials/aspnetcore.html) & despite making the
changes you mentioned it doesn't work. Same works with ASP.NET Core 2.0
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#433 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA5hFrV-YJSXXwyPpGomTZlS7BcD7SNkks5uvbSEgaJpZM4O1zVG>
.
|
This worked perfectly. Thanks so much! Saved me a real headache. |
@ShikiGami - your fix worked for me too. Thanks! |
After having followed the first part of the tutorial, I try to run the web site and it throws on startup with
Is this just the result of a breaking change by AspNetCore 2.0? Is there an incoming fix?
The text was updated successfully, but these errors were encountered: