Deploy asp.net react template without nodejs dependency on IIS server - asp.net

I'm having problems with deploying and running the ReactRedux template on an IIS server which doesn't has nodejs. The app was created using AspNetCore.SpaTemplates' "reactredux" option:
https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
The app is the same as the template, no changes were made. We first tried to host it on IIS with nodejs installed on the IIS server, everything works fine:
screenshot with nodejs
But when we uninstalled nodejs from the server and restarted IIS, it wasn't working anymore:
screenshot without nodejs
We couldn't figure out what the error is because running it in development mode requires nodejs and when we run it with dotnet run in development mode the error message complains about node.js not being installed, as expected.
We tried to deploy the app running:
$Env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet publish -c Release
and using Visual Studios build>publish interface.
Acording to the docs here, the app shouldn't need nodejs when its deployed for production:
https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio
Unlike the development build, the production build doesn't require
Node.js to be installed on the server.
I'm new to asp.net and deploying apps on IIS, maybe the solution is trivial but we couldn't manage to solve this, thanks in advance.

If you don't want any nodejs dependency, make sure you disabled server-side prerendering:
https://github.com/aspnet/JavaScriptServices/issues/932
If you're not doing server-side prerendering, then you will not need
Node.js on your production server, because all the JS will be executed
on the client side.
If you are doing server-side prerendering (which is the default in the
React-Redux template in this repo), then you do need Node.js on your
production server, because the prerendering process involves executing
your JavaScript code on the server.
To disable server-side prerendering do the following:
Remove asp-prerender-module="ClientApp/dist/main-server" from Views>Home>Index.cshtml
Remove #addtaghelper "*, Microsoft.AspNetCore.SpaServices" from Views/_ViewImports.cshtml

Related

Unable to publish the artifact for .NET Core on Azure Devops (pipeline)

Unable to publish the artifact for .NET Core, I can able to build but can't publish on Azure Devops.
Frontend: Angular
Backend: .NET Core 6
SQl : MSSQL server
Front code : Angular,
Back end : dotnet 6,
Sql : MSsql Server
Given that your project could be restored correctly, I suppose that you could add a --no-restore to your dotnet publish argument and test again.
Updated on 1/2
======================================================
I suppose there are multiple possible caused for your current issue of https 500.30. You could visit this doc to troubleshoot.
Additionally,
1.Check your hosting model. Confirm that whether it's IN Of Process or Out of Process. You can check the configuration in you csproj file. if you using In of Process, try to change it to
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
2.If you are deploying win-x64 app and try to have it published using an Application Pool that supports 32-bit apps, you will need to make them match-up.
3.Check in portal.azure.com for your web-app whether it is running correctly.
4.Go to portal.azure.com check you app console, and try to manually start your project with dotnet ServerApp.dll.
==========================================================
Updated on 1/9
Hi devendar
Check this doc Bad Gateway errors in Application Gateway for further troubleshoot.

How to run Blazor Web Assembly locally

Is it possible to run a Blazor Webassembly app after publishing from the file system, invoking the index.htm in wwwroot? If I do this, the app doesn’t run. The console shows the following errors:
How can I fix this? Or is it not possible to execute the app in this way?
(For info, this is the .Net 6 Blazor Wasm template without any changes, just created and published the template.)
You can use any number of web servers to do that - this is my opinionated answer
https://www.nuget.org/packages/dotnet-serve/#readme-body-tab
Get started
Install .NET 5 or newer and run this command:
dotnet tool install --global dotnet-serve
Start a simple server and open the browser by running
dotnet serve -o
..and with HTTPS.
dotnet serve -o -S

Node.js is generally code running on the server; what role does it play in front-end project development?

Generally, when writing vue.js front-end projects, node.js is used. For example, npm installs some node.js three-party packages to node_modules/.
Excuse me, node.js is generally the code running on the server side; what role does it play in front-end project development? Is it just npm run dev to run the webserver like this?
Or can Node.js also write some front-end code? But Node.js is a program running on the server, how can you write front-end code?
First of all, Node.js is a runtime environment that can run JavaScript, which is similar to the JavaScript runtime environment embedded in the browser. In fact, Node.js is ported from Chorme's built-in V8 JavaScript runtime environment;
Then, Node.js can be used as a server, running the server. It can also be used as a scripting tool. Now the front-end package management and packaging tools are all Node.js scripts;
To sum up, the difference between front-end code and back-end code is: where does it run? The client (front-end) runs client-side code, and the server-side runs server (back-end) code.
Node.js is a runtime environment. There is no such thing as writing front-end or back-end code. It can be said that it runs front-end packaging scripts, and runs JavaScript server-side code. The JavaScript server can serve the front-end, such as server-side rendering.

Meteor deployed site always displays "This site is down. Try again later."

I created a meteor app which works fine on my localhost.
I recently just deployed my app to meteors server for testing and each time I visit the app I get a page with the text
This site is down. Try again later.
When I deploy I type:
meteor deploy [app-name]
It deploys successfully but when I actually visit the site, it says it is down.
I’ve tried the following:
Deleting the deployed app and re-uploading, but I experience the same error.
Deploying a brand new meteor app, still says same site is down error.
Deleting the app, reseting my local database with meteor reset, and redeploying. Same error.
Can I do something to fix this, or is this an error with Meteor's servers?
--------------------UPDATE-----------------------
The site is not showing because it is crashing. Using Meteor logs [app-name] I was able to find out that it was crashing because it cannot find module async.
I have my meteor project setup for NPM integration. I used npm install async and use
async = Meteor.require('async')
But I think the issue is with my package.json file.
Here is my current package.json
{
"async": "0.9.0"
}
Is meteor not able to install async on the server because this package.json file is incorrect? Everything works on my localhost but I used npm install async specifically.
----------------------------UPDATE 2-----------------------
I fixed it with the help of this thread:
How can I deploy node modules in a Meteor app on meteor.com?
You have to be a bit careful with NPM modules. meteor deploy doesn't support binary npm or installing npm modules via npm install from a package.json.
This may be what is causing you issues. Unfortunately, there isn't a way passed this. You could use your own server via DigitalOcean or AWS to get passed this.

How does Meteor Up work?

I recently created a droplet on Digital Ocean, and then just used Meteor Up to deploy my site to it.
As awesome as it was to not have to mess with all of the details, I'm feeling a little worried and out of the loop about what's happening with my server.
For example, I was using the console management that Digital Ocean provides, and I tried to use the meteor mongo command to investigate what was happening with my database. It just errored, with command not found: meteor.
I know my database works, since records are persistent across accesses, but it seems like Meteor Up accomplished this without retaining any of the testing and development interfaces I grew used to on my own machine.
What does it do??? And how can I get a closer look at things going on behind the scenes?
Meteor Up installs your application to the remote server, but does not install the global meteor command-line utilities.
For those, simply run curl https://install.meteor.com | /bin/sh.
MUP does a few things. Note that this MUP is currently under active development and some of this process will likely change soon. The new version will manage deployment via Docker, add support for meteor build options, and other cool stuff. Notes on the development version (mupx) can be found here: https://github.com/arunoda/meteor-up/tree/mupx.
mup setup installs (depending on your mup.json file) Node, PhantomJS, MongoDB, and stud (for SSL support). It also installs the shell script to setup your environment variables, as well as your upstart configuration file.
mup deploy runs meteor build on your local machine to package your meteor app as a bundled and zipped node app for deployment. It then copies the packaged app to the remote server, unbundles it, installs npm modules, and runs as a node app.
Note that meteor build packages your app in production mode rather than the debug mode that runs by default on localhost when you call meteor or meteor run. The next version of MUP will have a buildOptions property in mup.json that you can use to set the debug and mobileSettings options when you deploy.
Also, since your app is running directly via Node (rather than Meteor), meteor mongo won't work. Instead, you need to ssh into the remote server and call mongo appName.
From there, #SLaks is right about how it sets things up on the server (from https://github.com/arunoda/meteor-up#server-setup-details):
This is how Meteor Up will configure the server for you based on the given appName or using "meteor" as default appName. This information will help you customize the server for your needs.
your app lives at /opt/<appName>/app
mup uses upstart with a config file at /etc/init/<appName>.conf
you can start and stop the app with upstart: start <appName> and stop <appName>
logs are located at: /var/log/upstart/<appName>.log
MongoDB installed and bound to the local interface (cannot access from the outside)
the database is named <appName>

Resources