pauldotknopf / javascriptviewengine Goto Github PK
View Code? Open in Web Editor NEWAn ASP.NET MVC ViewEngine for rendering markup in a JavaScript environment. Ideal for React and Angular server-side rendering.
License: MIT License
An ASP.NET MVC ViewEngine for rendering markup in a JavaScript environment. Ideal for React and Angular server-side rendering.
License: MIT License
Hi.
Whenever i set
nodeEngine.NodeHostingModel = Microsoft.AspNetCore.NodeServices.NodeHostingModel.Socket;
the fisrt request to the site is ok, ie, node.exe starts, page loads ok. If I head to other page the browser just keeps loading and nothing happens.
Do i need anything else to have this mode working?
Thank you!
Telmo
Compiling JavaScriptViewEngine for .NETCoreApp,Version=v1.0
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:04.3719335
Expect required library hostpolicy.dll to be present in [C:\Projects\JavaScriptV
iewEngine\src\JavaScriptViewEngine\bin\Debug\netcoreapp1.0]
What is wrong here?
Is this supposed to run under rc2?
I know the line of JS that's causing the internal server error, but I don't know why. How can I debug what's running inside the view?
The problem is that I don't know why and I can't see any obvious way to trouble-shoot the problem.
EDIT: Specifically the code that runs perfectly on the client but breaks on the server view rendering is:
new ApiClient()['get']('api/people/load').then((data) => {
stores.people = data;
});
That's the code in the loadPeople
method.
Hi Paul,
I just run the "dotnet run" command and all works fine with the boilerplate but when i run the solution with visual studio 2015 i have an issue with the "already existing NODE_PATH key", i think that can be resolved with this fix aspnet/JavaScriptServices@a881ca5 in this file JavaScriptViewEngine/src/JavaScriptViewEngine/NodeServices/HostingModels/OutOfProcessNodeInstance.cs on line 69.
I hope it help you.
Pol
Hi,
Just a quick question to ask whether you use this in production? Or plan to?
And did you run benchmarks for it?
Thanks
Tim
I was just wondering if you can explain the "js-{auto}" portion of this code
return View("js-{auto}", new GreetingViewModel { Greeting = greeting });
and the $"js-/statuscode{statusCode} in this code
return View($"js-/statuscode{statusCode}", await BuildState());
Using Webpack and React. I have a server.js
build to wwwroot/dist/server.js
which is the one I would like to use.
I have tried to set it like the following in configure but still get an error.
services.Configure<RenderPoolOptions>(options => {
options.WatchPath = Path.Combine(environment.WebRootPath, "dist");
options.WatchFiles = new List<string> {
Path.Combine(options.WatchPath, "client.js"),
Path.Combine(options.WatchPath, "server.js")
};
});
The error is:
Exception: Call to Node module failed with error: Error: Cannot find module '<repo>\wwwroot\default'
Is there a different way to set this value?
When building and running with the newly released ASP.NET Core 1.0, it fails on runtime:
System.TypeLoadException
Could not load type 'Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions' from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(object target, Object[] arguments, Signature sig, bool constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(object obj, Object[] parameters)
at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.Invoke(object instance, IServiceCollection exportServices)
at Microsoft.AspNetCore.Hosting.Internal.<>c__DisplayClass4_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
on services.AddJsEngine();
in Startup.cs
.
I'm not really sure how I got this exception but I think its happening when an empty object is passed into the enhancer at the end of configure store like this:
export default function configureStore(initialState, history) {
const state = {};
const enhancer = compose(
applyMiddleware(thunk),
applyMiddleware(routerMiddleware(history)),
devTools
)(createStore);
return enhancer(reducers, state);
}
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.WriteAsync(string)' and 'System.IO.TextWriter.WriteAsync(char[])'
at CallSite.Target(Closure , CallSite , TextWriter , Object )
at CallSite.Target(Closure , CallSite , TextWriter , Object )
at JavaScriptViewEngine.JsViewEngine.JsView.<RenderAsync>d__8.MoveNext()
It appears to be coming from one of these two lines:
I'll try to set up a project tonight that makes this reproducible for you since I can't share the project the error is happening in.
The link in the readme for "react-aspnet-boilerplate" points to a dead link at:
https://github.com/pauldotknopf/JavaScriptViewEngine/blob/master/react-aspnet-boilerplate
The correct link should be:
https://github.com/pauldotknopf/react-aspnet-boilerplate
I would like to set some environment variables from the host ASP.NET application. I found out that JavaScriptService supports is: https://github.com/aspnet/JavaScriptServices/blob/fb19ee8923b5ef7ebb125bc6e5a1a182cfadfe88/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs#L90
Do you accept a PR that allows to set additional environment variable from NodeRenderEngineOptions?
Great project btw!
Are there any plans to update this library to support ASP.NET Core 2.0? I downloaded the source and it looks like all that needs to be done is to use InvokeExportAsync instead of InvokeExport in NodeRenderEngine.cs, as it was renamed in INodeServices.
Hi,
I pulled the latest and attempt to build using ./build.ps1
and I encounter errors from the Build
task about a missing JavaScriptViewEngine.Mvc5
project reference. Also attempt to load the solution in VS and the JavaScriptViewEngine.Mvc5
project doesn't load. Looking at the path in the .sln
file it's referencing src/JavaScriptViewEngine.Mvc5/JavaScriptViewEngine.Mvc5.csproj
, which doesn't appear to be in the repo. Perhaps an issue with .gitignore
?
Cheers!
how to use JavaScriptViewEngine for prerender angularjs in asp.net mvc5?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.