MVC 4,页面不刷新 - 获取动态CSS [英] MVC 4, Page does not refresh - Get Dynamic CSS
问题描述
我遇到了一些奇怪的问题。
我有一页是预览,使用最新设置预览屏幕(上一页执行所有设置,如字体颜色,图像上传等)。设置首选项后不久,我正在生成一个css文件。
现在,每次我必须执行CTRL + F5时更改才会生效。我该怎么做这个代码?
我已经禁用缓存并尝试使用Google搜索。
请帮忙。
注意:使用MVC4构建的应用程序,C# ,VS2012。在Chrome,IE,FireFox上测试。
问候
Vishnu Tej
Hi,
I got into some weird problem.
I have a page namely "Preview", which previews screen with latest settings(Previous page does all settings like font color, images upload...etc ). Soon after setting the preferences i'm generating a css file.
Now for the changes to take effect, everytime I have to do a CTRL+F5. HOW DO I DO THIS THRO CODE?
I've disabled cache and tried googling a lot.
Please help.
Note: Application built using MVC4, C#, VS2012. Tested on Chrome, IE, FireFox.
Regards
Vishnu Tej
推荐答案
我自己解决了这个问题...
i've resolved this by myself...
<script type="text/javascript">
window.onload = function () {
if (!window.location.hash) {
window.location = window.location + '#';
window.location.reload(true);
}
}
</script>
或
OR
<script type="text/javascript">
window.onload = function () {
if (window.location.hash == '') {
window.location = window.location + '#hashrl';
window.location.reload(true);
}
}
</script>
这篇关于MVC 4,页面不刷新 - 获取动态CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!