ASP.NET开发服务器未更新对标记/代码的更改 [英] ASP.NET Development Server is not updating changes to markup/code

查看:85
本文介绍了ASP.NET开发服务器未更新对标记/代码的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用ASP.NET开发服务器(在一个MVC项目中,我发现它在处理我对代码所做的更改方面不一致.例如,我对在开发环境中运行C#/HTML/CSS/JS并运行该页面,然后在屏幕上显示更改.但是,如果我再次编辑HTML并再次运行该页面,则不会出现新的更改,即使是ctrl + F5没有,我必须停止Web服务器,然后再次运行该应用程序以更新更改.是否有其他人遇到过这种情况?有没有办法解决此问题?

I've been working on the ASP.NET Development Server recently (on an MVC project and I'm finding that it is inconsistent in how it serves the changes I make to my code. For example, I make a change to the C#/HTML/CSS/JS in the dev environment and run the page, and the change appears on the screen. But if I edit the HTML again and run the page again, the new change doesn't appear. Even ctrl+F5 doesn't do it. I have to stop the web server and run the app again for the changes to update. Has anyone else experienced this? Is there a way to sort this problem out?

如果我在IIS中工作并且更改了某些内容,则ctrl + F5将始终使用所做的更改来更新页面.我希望开发服务器同样可靠.有人有什么建议吗?

If I'm working in IIS and I change something, a ctrl+F5 will always update the page with the changes I've made. I'd like the dev server to be as reliable. Does anyone have any suggestions?

推荐答案

尝试对每个请求清除缓存..

Try clearing cache.. on every request

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));

如果仍然无法正常工作.在pag load事件中尝试以下代码

If Still not work. Try this bunch of code in pag load event

Response.AppendHeader("Pragma", "no-cache"); 
Response.AppendHeader("Cache-Control", "no-cache");

Response.CacheControl = "no-cache"; 
Response.Expires = -1;

response.ExpiresAbsolute = new DateTime(1900, 1, 1); 
response.Cache.SetCacheability(HttpCacheability.NoCache);

这篇关于ASP.NET开发服务器未更新对标记/代码的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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