user4433985
user4433985

Reputation:

ASP.NET Core with Angular not updating changes

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.

Upvotes: 10

Views: 10379

Answers (6)

Jos
Jos

Reputation: 310

In my case it failed to update because it was still running under IIS Express. I solved it by changing the profile from "IIS Express" to [project name] (both in the VS task bar and in the project properties under "Debug").

Upvotes: 1

Leonardo Martins
Leonardo Martins

Reputation: 1

I have passed trought the same problem.

You have two options:

  1. Delete the "dist" folder(this folder will be recreated everytime you use 'ng-build')
  2. 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

Upvotes: 0

kavinbalaji
kavinbalaji

Reputation: 161

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.

Upvotes: 0

Ashu
Ashu

Reputation: 181

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")

enter image description here

Upvotes: 12

Paul D
Paul D

Reputation: 676

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.

Upvotes: 1

user4433985
user4433985

Reputation:

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.

Upvotes: 4

Related Questions