RyeGuy
RyeGuy

Reputation: 4483

HTML Changes Not Being Shown in Build for Visual Studio 2017

I am creating an app using Angular2 and ASP.NET Core in VS 2017. Unfortunately Google Chrome browser will not reflect my html changes upon build. In fact it is running pages that were deleted in my solution.

All the suggestions found here have not worked including 'empty cache and hard reload' or editing the web.config file or cleaning the solution.

visual studio not updating html / javascript to server / browser

Next I tried adding this tag to my root component html:

<meta http-equiv="pragma" content="no-cache" />

Still nothing.

After that I tried going to Tools -> Options

Under Projects and solution -> Build and Run select "Always build" under "On Run, when projects are out of date"

Nothing.

Last I tried changing the port it runs on by editing the Program.cs file with the statement

.UseUrls("http://localhost:5050")

and it STILL does not reflect my changes. This is super frustrating.

Please any advice would be great.

Upvotes: 1

Views: 2814

Answers (3)

FCouples
FCouples

Reputation: 441

I had this in my Startup.cs

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        ....
        app.UseSpaStaticFiles();

after removing it I can see the changes

Upvotes: 0

benjones
benjones

Reputation: 31

In addition to the step mentioned above, you might need to check that the Development environment variable has been set (ASPNETCORE_ENVIRONMENT). I found the project did not set this up, nor did it set the profile to launch in IIS Express either.

Upvotes: 1

RyeGuy
RyeGuy

Reputation: 4483

I fixed this issue by opening the Startup.cs and changing the ConfigureServices method to use the DeveloperExceptionPage. The browser console or VS would not display any build errors but they were there.

Startup.cs

    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
        {
            HotModuleReplacement = true
        });
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
    }

Upvotes: 2

Related Questions