[英]Visual Studio 2013 caching older version of .js file
I am working on a small web api project in Visual Studio 2013 Ultimate.我正在 Visual Studio 2013 Ultimate 中开发一个小型 Web api 项目。 Windows 2013. Internet Explorer 9. When I run (debug) from VS using the internal web server (I guess that is IIS Express, now), I am finding that the changes I am making (and saving) to a javascript page are being ignored.
Windows 2013. Internet Explorer 9. 当我使用内部 Web 服务器(我想现在是 IIS Express)从 VS 运行(调试)时,我发现我正在对 javascript 页面进行(并保存)更改忽略。 Placing a breakpoint in the javascript shows the older code without my changes.
在 javascript 中放置断点会显示没有我更改的旧代码。
CTRL+F5 does not force the application to use the currently updated page. CTRL+F5 不会强制应用程序使用当前更新的页面。 Checking the page in, then checking it back out often works.
签入页面,然后将其签出通常是可行的。 Is there some setting or trick that will help me out here?
有什么设置或技巧可以帮助我吗?
Clearing the cache history seemed a bit excessive and I don't want to do that all the time.清除缓存历史似乎有点过分,我不想一直这样做。
The following solution worked me in Internet Explorer: First enable script debugging:以下解决方案在 Internet Explorer 中对我有用:首先启用脚本调试:
Then make sure you get the newest page:然后确保您获得最新的页面:
If somebody has this problem and ctrl+F5, clearing browser's cache, restarting debugging, changing browser, changing web.config and rebuilding project don't help, then there is one last thing that works (at least for me): restart Visual Studio .如果有人遇到此问题并且 ctrl+F5、清除浏览器缓存、重新启动调试、更改浏览器、更改 web.config 和重建项目没有帮助,那么最后一件事(至少对我来说)有效:重新启动 Visual Studio .
Also changing debugging port on local IIS Express helps but this is far more painful if working in a team or using Azure Active Directory etc.更改本地 IIS Express 上的调试端口也有帮助,但如果在团队中工作或使用 Azure Active Directory 等,这会更加痛苦。
Only solution that worked for me was changing the javascript file name and updating the bundle configuration to point at the new file.唯一对我有用的解决方案是更改 javascript 文件名并更新捆绑配置以指向新文件。 I tried everything else from restarting my pc, deleting bin/obj/cache/etc, CTRL F5, restart IIS, and so on.
我尝试了其他所有方法,包括重新启动我的电脑、删除 bin/obj/cache/etc、CTRL F5、重新启动 IIS 等等。
If I'm correct you should build (ctrl+shift+b) your project before debugging.如果我是正确的,您应该在调试之前构建 (ctrl+shift+b) 您的项目。 This web server runs in the background on a port of choosing whenever you start in debug mode.
每当您在调试模式下启动时,此 Web 服务器都会在选择的端口上在后台运行。 You can close the task(s) (process bar next to your clock) if you need a new session or press F5 in VS.
如果您需要新会话或在 VS 中按 F5,您可以关闭任务(时钟旁边的进程栏)。
You can avoid using the built in web server if you have IIS (Express) or something similar.如果你有 IIS (Express) 或类似的东西,你可以避免使用内置的 web 服务器。 Go to RUN and type
iis
depending on your OS it's already installed.转到 RUN 并键入
iis
,具体取决于已安装的操作系统。 Otherwise try to install it in Control Panel
> Programs or Features
> Turn windows features on or off
否则尝试在
Control Panel
> Programs or Features
> Turn windows features on or off
中安装它
127.0.0.1 hostname
(c:\windows\system32\drivers\etc\hosts)127.0.0.1 hostname
(c:\windows\system32\drivers\etc\hosts) To debug your project in Visual Studio:在 Visual Studio 中调试您的项目:
Depending on how your solution/project is setup, you can publish your project files directly to IIS if you choose to publish to File System
.根据您的解决方案/项目的设置方式,如果您选择发布到
File System
,您可以将项目文件直接发布到 IIS。 Right mouse click on your project and choose publish
.右键单击您的项目并选择
publish
。 Set it up from there.从那里设置它。
If your Visual Studio is up-to-date you can publish single files with alt+$+p
.如果您的 Visual Studio 是最新的,您可以使用
alt+$+p
发布单个文件。
Hope it helps.希望能帮助到你。
Locate the code section where the JavaScript file is loaded to the page and add a parameter string to the end for testing.找到页面加载JavaScript文件的代码段,并在末尾添加参数字符串进行测试。 For example:
例如:
Change src="../Resources/js/MyScriptFile.js"更改 src="../Resources/js/MyScriptFile.js"
To src="../Resources/js/MyScriptFile.js?v=23"到 src="../Resources/js/MyScriptFile.js?v=23"
Every time you update your JavaScript file, you change the version number.每次更新 JavaScript 文件时,都会更改版本号。 This will force the browser to load your new version of JavaScript file.
这将强制浏览器加载新版本的 JavaScript 文件。 After you finished testing, You can remove the string "?v=23".
完成测试后,您可以删除字符串“?v=23”。 The bonus, if you leave it there, the end user will not be required to refresh his/her browser cache after you deployed your code to production.
奖金,如果你把它留在那里,在你将代码部署到生产环境后,最终用户将不需要刷新他/她的浏览器缓存。
I keep getting this problem very often.我经常遇到这个问题。 Normally what I do is first get into the drive where the OS is installed (In my case
C:
), and delete all the application.dll
and application.pdb
(it is stored in Windows\Microsoft.net\Framework\vx.x.xxxxx\Temporary ASP.NET Files
).通常我要做的是首先进入安装操作系统的驱动器(在我的情况下是
C:
),并删除所有application.dll
和application.pdb
(它存储在Windows\Microsoft.net\Framework\vx.x.xxxxx\Temporary ASP.NET Files
)。 Delete application.dll
and application.pdb
in the users\xxx
.删除
users\xxx
中的application.dll
和application.pdb
。 Get into the application directory and again delete application.dll
and application.pdb
.进入应用程序目录并再次删除
application.dll
和application.pdb
。 Clear the browser cache.清除浏览器缓存。 Restart the system (cold restart).
重新启动系统(冷启动)。 Build the application.
构建应用程序。 Most of time found to be working.
大部分时间都在工作。 Note: I use DOS prompt for deleting since I'm quite used to it.
注意:我使用 DOS 提示符进行删除,因为我已经习惯了。 But the user should have admin privileges.
但是用户应该有管理员权限。 It's not a perfect solution but it works.
这不是一个完美的解决方案,但它有效。
What worked for me was对我有用的是
So i had the same problem and i could avoid this by canceling the .ASP.NET-Server .ASP.NET-Server from Visual Studio for debugging from Visual Studio and restarting the debugging.所以我遇到了同样的问题,我可以通过取消 Visual Studio 中的 .ASP.NET-Server .ASP.NET-Server 以从 Visual Studio 进行调试并重新启动调试来避免这种情况。 Hope this helps someone.
希望这可以帮助某人。
I restarted Visual Studio and rebuilt the project, but the problem persisted for me -- the debugger continued to run an old copy of the .js file.我重新启动了 Visual Studio 并重建了项目,但问题仍然存在——调试器继续运行 .js 文件的旧副本。 The solution for me was to simply reboot the machine.
我的解决方案是简单地重新启动机器。 (When all else fails...)
(当一切都失败了......)
For reference, I'm currently using Visual Studio 2015.作为参考,我目前使用的是 Visual Studio 2015。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.