visual studio not updating html / javascript to se

2019-01-14 06:56发布

This is an MVC 4 app using the Hot Towel SPA template. Whenever I change anything in the HTML and/or javascript the only way I can get the new code to display is to clear the browser cache. F5, cntrl-F5, shift-F5, nothing works.

I'm not normally a web dev and just learning this. I've done regular MVC before and not had this issue, maybe it has to do with where the HTML and javascript is in my project (i.e. in the /App folder) ?. I'm going nuts trying to figure this out.

I can completely delete an HTML file and run the app and it still runs as it did. Clear cache and run and I then get the update.

It's running using IIS express using Firefox, Chrome, IE...

Thanks..

10条回答
放荡不羁爱自由
2楼-- · 2019-01-14 07:15

Go to your web.config file and make a change in it.Its not matter what change you make.For example type a character and then delete it and build the project and run it again.I hope it works.

查看更多
孤傲高冷的网名
3楼-- · 2019-01-14 07:18

In case disabling the cache and editing the web.config file does not work.

Simply close the solution and reopen it and try it. Strange, but it worked for me.

查看更多
虎瘦雄心在
4楼-- · 2019-01-14 07:19

In Opera and Chrome (and possibly others), you can disable caching while in 'development mode'.

While in DevTools, the 2nd option in the Settings menu is

Disable cache (while DevTools is open)

查看更多
放荡不羁爱自由
5楼-- · 2019-01-14 07:20

The browsers cache by default. You can turn off caching in your browser to get the changed files.

查看更多
Viruses.
6楼-- · 2019-01-14 07:20

I found that I had the .js file open in the Chrome Developer Tools -> Sources View.

When I closed the file there and refreshed the page the new .js file showed up as expected.

查看更多
【Aperson】
7楼-- · 2019-01-14 07:23

I had an issue with moved .ts & .html files on the server and had to:

  1. stop debugging
  2. clear the whole output/dist folder inside my ClientApp
  3. start debugging again
  4. Ctrl-F5 to force the cache to refresh on the browser

Simply disabling the browser's cache, or forcing the .net app to recompile, or even running ng serve had no effect.

查看更多
登录 后发表回答