如何在Visual Studio中调试时强制Chrome浏览器重新加载.css文件? [英] How to force Chrome browser to reload .css file while debugging in Visual Studio?

查看:347
本文介绍了如何在Visual Studio中调试时强制Chrome浏览器重新加载.css文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编辑Visual Studio 2012内的.css文件(在调试模式下)。我使用Chrome作为我的浏览器。当我在Visual Studio中对我的应用程序的.css文件进行更改并保存时,刷新页面将不会加载我的.css文件中已更新的更改。我认为.css文件仍然被缓存。



我曾尝试过:


  1. CTRL / F5


  2. 在Visual Studio 2012中,
    转至项目属性,Web选项卡
    在开始操作部分中选择启动外部程序
    粘贴或浏览至谷歌浏览器的路径(Mine是C:\ Users \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'行参数框放置-incognito

  3. 使用Chrome开发人员工具,单击齿轮图标,选中禁用缓存。

除非手动停止调试(关闭Chrome),重新启动应用程序(在调试中) p>

有什么方法可以强制Chrome始终重新加载所有css更改并重新加载.css文件?



更新:

1.刷新时,我的.aspx文件中的内嵌样式更改会被拾取。但.css文件中的更改不会。
2.它是一个ASP.NET MVC4应用程序,所以我点击一个超链接,它执行一个GET。这样做,我没有看到样式表的新请求。但是单击F5,.css文件将被重新加载,状态代码(在网络选项卡上)为200. 更复杂的解决方案,但一个非常简单,简单的方法就是将随机查询字符串添加到CSS include中。

例如 src =/ css / styles.css?v = {random number / string}



如果您使用php或其他服务器端语言,您可以使用 time()自动执行此操作。所以它会是 styles.css?v =<?= time();?>



方式,查询字符串将每次都是新的。就像我说的那样,有更复杂的解决方案更具动态性,但在测试中这种方法是顶级(IMO)。


I'm currently editing a .css file inside of Visual Studio 2012 (in debug mode). I'm using Chrome as my browser. When I make changes to my application's .css file inside of Visual Studio and save, refreshing the page will not load with the updated change in my .css file. I think the .css file is still cached.

I have tried:

  1. CTRL / F5
  2. In Visual Studio 2012, Go to project properties, Web tab Choose Start External Program in the Start Action section Paste or browse to the path for Google Chrome (Mine is C:\Users\xxx\AppData\Local\Google\Chrome\Application\chrome.exe) In the Command line arguments box put -incognito
  3. Used the Chrome developer tools, click on the "gear" icon, checked "Disable Cache."

Nothing seems to work unless I manually stop debugging, (close out of Chrome), restart the application (in debug).

Is there any way to force Chrome to always reload all css changes and reload the .css file?

Update:
1. In-line style changes in my .aspx file are picked up when I refresh. But changes in a .css file does not. 2. It is an ASP.NET MVC4 app so I click on a hyperlink, which does a GET. Doing that, I don't see a new request for the stylesheet. But clicking F5, the .css file is reloaded and the Status code (on the network tab) is 200.

解决方案

There are much more complicated solutions, but a very easy, simple one is just to add a random query string to your CSS include.

Such as src="/css/styles.css?v={random number/string}"

If you're using php or another server-side language, you can do this automatically with time(). So it would be styles.css?v=<?=time();?>

This way, the query string will be new every single time. Like I said, there are much more complicated solutions that are more dynamic, but in testing purposes this method is top (IMO).

这篇关于如何在Visual Studio中调试时强制Chrome浏览器重新加载.css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆