问题
I have created a new project following this tutorial https://www.youtube.com/watch?v=ytDTkFJOJIE using aspnet core spa templates (angular to be specific).
So when I run "dotnet run" the first time it works fine, it runs the site as to be expected.
Now, when I commit a change, like delete the navbar and the references to it, the "main-server.js" and "main-client.js" don't update, nor does the site in the browser.
What am I doing wrong? If any more info is needed, let me know.
回答1:
I was facing same issue. Below steps worked for me:
- Delete all files from dist folder
- run "ng build"
- When the application runs, if you still don't see the changes, Empty cache and hard reload the chrome browser (hold browser refresh button for long, and select "Empty cache and hard reload")
回答2:
It appears to be I had to set the environment variable. Although it might be set on launchSettings.json, you have to run this command
$Env:ASPNETCORE_ENVIRONMENT = "Development"
for it to work properly. Took me since yesterday to find this, hope it helps someone else.
回答3:
For me the problem was Visual studio had checked in the .js and .js.map files for a few of my .ts components.
Visual Studio also checks in the main-client.js, vendor.js, and vendor.css files by default. Makes sure to either remove these from source control (recommended) or check them out before running.
回答4:
I too faced this problem while i executed my angular 7 with.net core app in IIS express in VS2017,
- solved this by building the angular app(clientapp) in cmd by "ng build".
- Then, close and reopen the application. so that VS loads the project again.
- Now run the app using IIS express.
- this worked for me. so give a try.
回答5:
I have passed trought the same problem.
You have two options:
- Delete the "dist" folder(this folder will be recreated everytime you use 'ng-build')
- Make the implementation equals the link below. This implementation makes the application ignore the dist folder. It will only be used at production environment.
Implementation
来源:https://stackoverflow.com/questions/45490085/asp-net-core-with-angular-not-updating-changes