Can't run html pages in empty asp.net core project - asp.net-core-1.0

I am following some instructions to learn angularjs and WebAPi, but am running into an issue creating a new empty project.
Everytime I try to run the index.html page that I created in wwwroot, I am getting a 404 error.
If I just load the index.html from file explorer, it works fine.
Since I have been trying to troubleshoot this issue for a while, I decided to try to create a new Web Application project, to see if the starter project will work, and it works fine, including the index.html that copied from my other project.
So I am confused as to why I cant get iis to launch my pages in an empty project solution, I tried to recreate it 4 times, using a combination of either Microsoft.ASPnetcore.MVC as a dependency, or reverting back to Microsoft.ASPnet.Mvc
This is what my project.json's dependences looks like
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0"
},
I also compared it to the Web Application templete, and aside from the logger dependencies, there is nothing different.
I don't want to use the web application template, as it takes more time to remove all the junk that I don't need for my upcoming projects.
Any help would be appreciated.
`

It started working fine this morning, although I can only use Microsoft.AspNetCore.Mvc, my applications no longer like the old references to Microsoft.AspNet.Mvc

Related

Angular SSR Hot reload not working, no error, hung

I added angular universal to my project and upon saving, it compiles successfully though in the network tab I can see the request for whatever route im on gets hung on pending and the website stays loading forever in the browser. This issue is not present during CRS. Things I have tried that did not work:
I have cloned the same project elsewhere to see if it was some fat finger accident
I have not only add logic to stop DOM methods from being used, I have outright removed the use of them everywhere in the app
I added 3rd party libraries like Domino js to mock methods on Node
I started a completely blank angular project, added nothing to it other than angular universal and I get the same issue!
I will try it on another computer soon to see if it is just an issue on this machine.
What could the issue be? I don't get any errors and refreshing the page it works.
Is hot reload broken for me? missing anything?
EDIT: I have now tried it on a 2 other Windows machines and the result is the same. Perhaps this is a bug. Essentially makes Angular useless to me.
Angular Version 12.1
I was able to get it to work by upgrading my Angular to version 14, and starting a fresh project with SSR added. Frustratingly to say the least but I can finish my project and I copied back in most of my code from the project I was working on.
For what ever reason Angular 11 and 12 were giving me this issue on multiple machines on fresh angular projects. It never gave me any errors to show. I will report back if any time during the rest of the porting of code if the issue persists.
I had the same hassle when initially integrated the Angular Universal to my project.
After a period of time I consider the according workaround:
SSR for the single page applications is useful in production for SEO, Open Graph, etc.
Angular Universal adds additional files:
main.server.ts
app.server.module.ts
Then the classic angular approaches are still possible to be used (the old app.module.ts).
Now for the local development environment I'm continue using the classic "ng serve" command and the Angular continue reloads normally on each file change.
And the SSR is compileing only for the production build.
Then if I want to debug something related to the SSR I'm deploying the production build to the test environment and calling the test urls to see the results.

Issue with nuxtJs, vuetify and azure

I deployed a static web app, made in nuxtJs with vuetify.
All is working very well locally but once deployed, I cant see all component done with vuetify.
I follow those instructions : https://nuxtjs.org/deployments/azure-static-web-apps/
Thank you.
To deploy your nuxt.js app you need to follow the below workaround :
Please make sure that you have add the following in your package.json
"scripts": {
"dev": "nuxt dev",
"build": "nuxt generate"
},
If the website does note immediately load, then the background GitHub Actions workflow is still running. Once the workflow is complete you can then click refresh the browser to view your web app.
To check the status you can navigate as shown below or you can use this https://github.com/<YOUR_GITHUB_USERNAME>/repository name/actions
For more information please refer the below links:
Microsoft Documentation : Deploy server-rendered Nuxt.js websites on Azure Static Web Apps
SO THREAD : Azure static web apps not loading page resources correctly. css or javascript files
From the sample, you may be using routes.json - note that, the functionality defined in the routes.json file is now deprecated and better implemented in the Azure Static Web Apps configuration file.
Kindly see these docs for sample configuration and see if that helps.
https://learn.microsoft.com/azure/static-web-apps/configuration#routes
https://github.com/Azure/static-web-apps/wiki/routes.json-reference-(deprecated)
To benefit the community, added our discussions from Q&A forum.

Azure create the most basic App Service to serve static files with or without Node through the Portal

I am very confused about how App Service works internally.
I was exploring it and wanted to create a simple App Service through the portal to serve static files but only found a tutorial that uses a shell, not the Azure portal, that also requires services such as storage I don't need.
Here's what I've tried:
Got a subscription and created a resource attached to the free trial subscription
Create an App Service, basic (free) on Linux, using a new linux service plan and code (not container). I cannot choose any stack or runtime with only a static web server, so I select Node (LTS). I leave the startup command blank (later I'll expand on this). Http version 1.1 or 2 does not seem to make a difference. FTP enabled.
The resource is properly created, I can see the typical hosting start web
I connect to SFTP and I can see I have a path site/wwwroot with a single file hostingstart.html that looks exactly like the welcome page on the screenshot that I see when I access the website URL. I think to myself: "great! I can simply edit this html and I should see the result". Wrong. It does not seem to be the html being served. Not sure why it's there but if I remove it, I still see the same landing page on my site's URL.
I create an site/wwwroot/index.html but no luck. It's not being served. Maybe Node is not configured by default to do so.
I create a simple server.js that is capable of serving statically any file: https://github.com/TheJaredWilcurt/NPM-Free-Server So I use FTP to place a site/wwwroot/server.js and I leave an index.html (in my localhost it works :) ).
I configure in App Service a initial command like node server.js so that it can run and serve the page and I restart the server. Nothing, no effect.
I can see on the logs that my server.js is running. I can see a trace that says it's running on localhost:8000
At this stage it's been several hours investigating without luck. It can't be that hard!
I find the following question surprisingly not answered: https://github.com/MicrosoftDocs/azure-docs/issues/32572#issuecomment-551053105
Could anybody shed some light on this? I am open to suggestions. My goal is: To have (only) an App Service serving a static index.html with a hello world created through the Portal.
Ta!
UPDATE 1: Thanks to https://stackoverflow.com/users/188096/gaurav-mantri for his suggestion. But I'd like to put emphasis on App Service being required as it's for training purposes and I'd like to go from very basic up to more complex dynamic app with the same service and continuous deployment.
If all you care about hosting static content and no server-side code, take a look at static website hosting in Azure Storage: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website. You don't really need to create an app service for that.
#iberodev I deployed a svelte app to app service. I used the Deployment Center. As you did I marked the app as Node 10 app.
The Azure deployment pipeline did run the npm run build and npm run start commands after spawning a docker container (at least I think so by looking at the log files at several places.)
"start": "sirv public --single -H 0.0.0.0" works fine
"start": "sirv public", this is the start command from original svelte template, this makes the docker container to fail starting.
Those are my experimentations so far.
I think but I am not sure; Azure will run the start command in package.json, this way my demo svelte app works.
sirv command comes from sirv-cli in package.json.
You can try other static file servers like serve if you wish.
This way you can develop and commit in phases to have a gradually enhancing app.
I am not sure about the sirv commands performance as a web server for prod. But you mentioned it is for training purposes, it will fit.
package.json
{
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --single -H 0.0.0.0"
},
"devDependencies": {
"#rollup/plugin-commonjs": "^11.0.0",
"#rollup/plugin-node-resolve": "^7.0.0",
"rollup": "^1.20.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.0.0"
},
"dependencies": {
"sirv-cli": "^0.4.4"
}
}
I faced the same issue and have not been able to figure out why the newly created webapps do not directly use the hostingstart.html files. This is true in many different tech stack configurations. However, I created a static html (css and js included) web app in azure using these steps.
This created a .Net based webapp, which was not available in the portal. It had options especially on the default pages, etc. I have now re-used this webapp for starting the project from scratch and keep building on top of it. Hope this helps.
I got this working when changed app plan to windows, app service windows, runtime .NET 5 and removed the hostingstart.html

Prevent Publishing Node Application

I have a nodeJS application that I am working on, which has a package.json file and some node-module dependencies. I do NOT want the application to ever be published on node. Only eventually will I host my application with something like Heroku. I am really concerned about it being published somehow. How do I have control and know that my application is not currently published.
Any help would be greatly appreciated!
Thank you!
In your package.json file, just set:
"private": true
Then, NPM won't publish it, even by accident. I also recommend setting "license": "UNLICENSED".
See also: https://docs.npmjs.com/files/package.json

Why Do We Keep Having to Re-Build Our React App to Test Changes?

New to React, and excited to be getting started with it.
Followed the tutorial connected to this project, which uses create-react-app to generate a new react application.
For some reason we can't test changes to the code live without re-building the entire app with npm run build (which is tedious and takes a long time).
Any pointers on how to get it to run the pre-built, non-production version of the app for development purposes?
This seems like it should be obvious, but for some reason we can't figure it out.
Change the start script to this:
"start": "react-scripts start",
And then use npm start.
The project you linked to has changed it. Most likely because they want to serve the app from a node.js application to showcase the security features they implemented.
I would say: Use another tutorial for now

Resources