ASP.NET Development Server is not updating changes to markup/code

戏子无情 提交于 2020-01-02 03:59:45

问题


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?

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?


回答1:


Try clearing cache.. on every request

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

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);


来源:https://stackoverflow.com/questions/3616389/asp-net-development-server-is-not-updating-changes-to-markup-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!