asp.net-mvc Visual Studio 不将 html/javascript 更新到服务器/浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15646447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 02:41:59  来源:igfitidea点击:

visual studio not updating html / javascript to server / browser

asp.net-mvcvisual-studioasp.net-mvc-4single-page-application

提问by Brian

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.

这是一个使用 Hot Towel SPA 模板的 MVC 4 应用程序。每当我更改 HTML 和/或 javascript 中的任何内容时,我可以显示新代码的唯一方法是清除浏览器缓存。F5,cntrl-F5,shift-F5,没有任何作用。

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.

我通常不是网络开发人员,只是在学习这个。我以前做过常规 MVC 并且没有遇到过这个问题,也许这与 HTML 和 javascript 在我的项目中的位置有关(即在 /App 文件夹中)?。我快要疯了,试图弄清楚这一点。

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.

我可以完全删除一个 HTML 文件并运行该应用程序,它仍然可以正常运行。清除缓存并运行,然后我得到更新。

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

它使用 IIS express 运行,使用 Firefox、Chrome、IE ...

Thanks..

谢谢..

回答by Mark Hebert

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

在 Opera 和 Chrome(可能还有其他)中,您可以在“开发模式”下禁用缓存。

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

在 DevTools 中,设置菜单中的第二个选项是

Disable cache (while DevTools is open)

禁用缓存(当 DevTools 打开时)

回答by Hamid Reza

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.

转到您的 web.config 文件并对其进行更改。您所做的更改无关紧要。例如,键入一个字符,然后将其删除并构建项目并再次运行它。我希望它有效。

回答by benscabbia

I also experienced this issue and turns out it was related to caching.

我也遇到过这个问题,结果证明它与缓存有关。

If using Chrome DevTools, you can simply disable cache by navigating to the NetworkTab and ticking Disable Cache

如果使用Chrome DevTools,您可以通过导航到Network选项卡并勾选来简单地禁用缓存Disable Cache

This will only disable the cache when Dev Tools is open.

这只会在开发工具打开时禁用缓存。

回答by user5695027

in my case iis express not updated site, but site , created by iis Manager worked correctly?

在我的情况下,iis express 没有更新站点,但是由 iis Manager 创建的站点工作正常吗?

possible solution for this problem is set "use this 64 bit version of iis express for web sites and projects" option at visual studio it located at options->Projects and Solutions->Web projects

这个问题的可能解决方案是在它位于选项->项目和解决方案->Web项目的visual studio中设置“将此64位版本的iis express用于网站和项目”选项

回答by Henry Aloni

ctrl+shift+F5 will do the trick! Seems like browser cache is part of the problem :)

ctrl+shift+F5 就能解决问题!似乎浏览器缓存是问题的一部分:)

回答by John Papa

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

浏览器默认缓存。您可以关闭浏览器中的缓存以获取更改的文件。

回答by Mark Miller

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

我发现我在Chrome Developer Tools -> Sources View 中打开了 .js 文件。

When I closed the filethere and refreshed the pagethe new .js file showed up as expected.

当我那里关闭文件刷新页面时,新的 .js 文件按预期显示。

回答by Locke1211

If you just want to test locally You can try

如果你只是想在本地测试你可以试试

A) Create Virtual Directory Follow below path: Project / Properties / Web
Find Servers section Click on Create Virtual directory

A)创建虚拟目录遵循以下路径:项目/属性/网络
查找服务器部分点击创建虚拟目录

B) Follow below path: Project / Properties / Web
Find Servers section Click on Drop down and change the selected value between Express and Local Then Create Virtual directory

B)按照以下路径:项目/属性/网络
查找服务器部分单击下拉并更改Express和Local之间的选定值然后创建虚拟目录

回答by monty

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

我在服务器上移动 .ts 和 .html 文件时遇到问题,不得不:

  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
  1. 停止调试
  2. 清除我的 ClientApp 中的整个 output/dist 文件夹
  3. 重新开始调试
  4. Ctrl-F5 强制缓存在浏览器上刷新

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

简单地禁用浏览器的缓存,或强制 .net 应用程序重新编译,甚至运行 ng serve 都没有效果。

回答by thebenman

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

如果禁用缓存和编辑 web.config 文件不起作用。

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

只需关闭解决方案并重新打开并尝试。奇怪,但它对我有用。