Aspnet Angular SPA template not working after updating to angular 5 - asp.net

I have updated aspnet JavaScriptServices angular template to Angular 5.0.2
everything looks fine but when it published i'm getting following error
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: No ResourceLoader implementation has been provided. Can't read the url "app.component.html"
Error: No ResourceLoader implementation has been provided. Can't read the url "app.component.html" at Object.get
If I turn off the server side prerendering, by removing asp-prerender-module="ClientApp/dist/main-server" then it will work fine without any issues.
Any ideas on this?
Note: I have done the changes to use AngularCompilerPlugin instead of AotPluginas well

Related

Enable Cors in Blazor Wasm

I want to add some cors policy in my blazorwasm app template.
After generating the app using "dotnet new blazorwasm", according to https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0 I add this line to Program.cs:
builder.Services.AddCors(...);
but it gave this compile error:
error CS1061: 'IServiceCollection' does not contain a definition for 'AddCors' and no accessible extension method 'AddCors' accepting a first argument of type 'IServiceCollection' could be found
It seems to be a balzor-wasm problem because if I start by "blazorserver" template it's OK.
After a little investigation I found that the 'CorsServiceCollectionExtensions' class (and many other ASP APIs) are not available. I even tried
dotnet add package Microsoft.AspNetCore.App.Ref
to add the nuget package manullay but that gave
error: Package 'Microsoft.AspNetCore.App.Ref' is incompatible with 'all' frameworks in project
As #HenkHolterman mentioned in comments, CORS is a Server feature. I was mixing Server/Client concept in Blazor. In fact I should add CORS in my web server that will host my blazor app (that could be an asp server or whatever else)
For example while creating an app using template of "blazorwasm" adding "--hosted" (dotnet new blazorwasm --hosted) will generate an asp server app too that is the right place to call AddCors

Spring Boot Jetty not supported on GAE, but causes my tests to fail when removed?

I am building out an API using Spring Boot, which is being deployed to Google App Engine with Travis CI.
I started my code from Google's Starter Project (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard), which doesn't use the spring-boot-starter-jetty dependency. As such, my project also did not not require it, and everything was deploying fine.
That was until I decided to add a test that uses Spring's TestRestTemplate.getForEntity() method to hit a basic endpoint I could assert on, just to give me some peace of mind that the endpoint could be reached end-to-end. However, I got the following error when running the test locally:
java.lang.IllegalStateException: Failed to load ApplicationContext
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
Looking around, it became apparent that I should add the spring-boot-starter-jetty, and the test started passing! Everything looked fine.
However, after committing and deploying to GAE, I now get a 500 Error when trying to hit the endpoint.
I did some digging in Stackdriver, and this is the error that's thrown:
java.lang.RuntimeException: javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable
I presume that JSR-356 support is required by spring-boot-starter-jetty, which I presume GAE doesn't support, hence the error. I have reported this upstream here: https://issuetracker.google.com/issues/79235250
Is there a way I can add the dependency without JSR-356 support, or is there another way I can get some form of HTTP End-To-End test to pass?
You can view my source code here: https://github.com/bytelucas/nohold - the test in question is HTTPRequestTest.java.
Looks like Spring boot defaults the starter jetty to 9.1, can you try overriding the default to earlier versions of jetty by adding it (in POM) which uses JSR-353 to see if that fixes the issue instead.

ASP.NET CORE 2 + ANGULAR 4: NodeInvocationException: Prerendering failed because of error: ReferenceError: window is not defined

I am trying to use ngx-chips for tag-input, but I am having this issue with importing BrowserAnimationsModule.
On importing BrowserAnimationsModule, I get the error below:
An unhandled exception occurred while processing the request.
NodeInvocationException: document is not defined
ReferenceError: document is not defined
Once I comment BrowserAnimationsModule in import under app.module.shared.ts, my app works normal but once I uncomment it, I come up with the same error.
Please how can I trash this, I have been working on this for more than 4days.
Or suggest any other angular 4 tag-input library
I am using ASP.NET Core 2 SPA Template.
Thanks...
In your view's (Index.cshtml) app tag, replace the asp-prerender-module with asp-ng2-prerender-module.

I need help to connect WebSocket SignalR

i have a problem to connect my app.js on my hubs/socket.js
when made my js and put the conecction
var stream = $.connection.sockets;
show my this error
app.js:2 Uncaught TypeError: Cannot read property 'sockets' of undefined
i coppy a example from other proyect and i don't know how does it work
i made the proyect in asp.net mvc in visual studio 2015
What is the order of js references you have made?
Also, have you added reference to the signalr jQuery library and signalr/hubs?

Meteor app works locally but will not load when deployed to meteor.com

I have no idea what to do here. Everything was working fine but all of a sudden when I deploy now I get cryptic errors
Uncaught TypeError: Cannot read property 'helpers' of undefined
bf828391c4c2197419ba1631eee96dfda64d3e0a.js:111 Uncaught TypeError: Cannot read property 'ServiceConfiguration' of undefined
memrey.meteor.com/:1 Document was loaded from Application Cache with manifest http://memrey.meteor.com/app.manifest
memrey.meteor.com/:1 Application Cache Checking event
bf828391c4c2197419ba1631eee96dfda64d3e0a.js:3 Exception in callback of async function: TypeError: Cannot read property 'form' of undefined
at x.setState (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:135:16160)
at a.contains.o.route.a.extend.onBeforeAction (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:142:3525)
at p (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:72:4036)
at http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:3:6711
at C (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:82:4631)
at p (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:72:4036)
at http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:3:6711
at b (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:82:4559)
at p (http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:72:4036)
at http://memrey.meteor.com/bf828391c4c2197419ba1631eee96dfda64d3e0a.js:3:6711
memrey.meteor.com/:1 Application Cache NoUpdate event
bf828391c4c2197419ba1631eee96dfda64d3e0a.js:64 Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
The code is working just fine locally. So I am lost. I don't even know where to begin debugging.
I am using iron router with useraccounts template package. I am not sure if it is related to that.
Ok I found out what the issue is.
When I defined a template helper like:
Template.notification.helpers
I misspelled notification
Which caused all the errors. But what is strange is that it worked locally but not when deployed.
Exceptions may be tolerated because they are in seperate files when working in development mode, however when deployed in production they're minified and join so the execution of the js file is stopped.
Source

Resources