IIS 清除多个缓存后仍然提供旧的 CSHTML 文件。

huangapple go评论60阅读模式
英文:

IIS serving old CSHTML file even after clearing many caches

问题

我们正在将一个ASP.NET Framework MVC Web应用程序部署到运行IIS 10.0的本地Windows Server 2019数据中心。我们以前已将相同的应用程序部署到运行IIS 7.5的本地Windows 2012服务器上,没有任何问题。然而,自从迁移到新服务器后,对特定的CSHTML文件的更改未在运行的网站中反映出来。

详细信息

  • Web应用程序在与其他ASP.NET应用程序相同的IIS服务器上运行,但没有一个应用程序遇到此问题。
  • 此Web应用程序是服务器上唯一的MVC应用程序,因此该问题可能只影响MVC应用程序。
  • CSHTML文件的唯一更改是锚点标签的href属性。在浏览器中检查文件时,它不使用更新的href
  • 失败的文件名为/views/cms/about.cshtml
  • 还有一个名为/views/home/about.cshtml的文件
  • 在修改了几个CmsController动作(AboutFooBar)之后,我们成功更改了/cms/foo/csm/bar的部署行为,但没有更改/cms/about,因此未调用About动作;因此,IIS似乎缓存了**/cms/about路由的结果,而不是/Views/Cms/About.cshtml文件**

我们目前正在与微软顾问通讯,但即使他们迄今为止也束手无策。任何想法都将不胜感激。

我们迄今为止尝试过的方法

  • 服务器上的cshtml文件是正确的,因此不是部署问题
  • 站点文件夹中所有文件(包括二进制文件)的“上次修改”日期是正确的
  • 清除浏览器缓存或从私密浏览上下文访问站点均无法解决问题,因此不是客户端问题
  • 服务器的本地主机仍提供旧页面,因此不是网络问题
  • 对静态资源的更改在浏览器中反映出来,因此该问题仅影响CSHTML文件
  • 即使删除或重命名文件后,仍提供旧版本的文件,因此很可能涉及某种缓存
  • 删除“Temporary ASP.NET Files”文件夹未解决问题。
  • 在IIS中回收应用程序池不会解决问题。
  • 在IIS中重新启动应用程序不会解决问题。
  • 重新启动IIS服务器不会解决问题。
  • 禁用输出缓存不会解决问题。
  • 尽管这个问题类似于这个问题,但列出的解决方法都不起作用。
  • 这个听起来类似,但不是长期解决方案。
  • 添加于2023年6月22日:重新部署应用程序不会解决问题

在每次尝试后,服务器仍然提供旧的CSHTML文件。

英文:

We are deploying an ASP.NET Framework MVC web application to an on-premises Windows server 2019 data center running IIS 10.0. We’ve previously deployed this same application to an on-premises Windows 2012 server running IIS 7.5 without any issues. However, since migrating to the new server, changes to a specific CSHTML file are not reflected in the running website.

Details

  • The web application is running on the same IIS server as other ASP.NET applications, not of which are experiencing this issue.
  • This web application is the only MVC application on the server, so the issue might only affect MVC applications.
  • The only change to the CSHTML file is the href attribute of an anchor tag. When examining the file in the browser, it does not use the updated href.
  • The failing file is named /views/cms/about.cshtml
  • There is another file named /views/home/about.cshtml
  • After modifying several CmsController actions (About, Foo, and Bar), we've successfully changed the deployed behavior for /cms/foo and /csm/bar, but not /cms/about, so the About action isn't being invoked; thus, IIS appears to be caching the result of the /cms/about route, not the /Views/Cms/About.cshtml file

We are currently corresponding with a Microsoft consultant, but even they are stumped thus far. Any ideas are appreciated.

What we’ve tried thus far

  • The cshtml files on the server are correct; thus, it is not a deployment issue
  • The “last modified” date of all files in the site folder – including binaries – are correct
  • Neither clearing the browser cache nor accessing the site from a private browsing context fixes the issue; thus, it is not a client-side issue
  • The server’s localhost serves the old page; thus, it is not a network issue
  • Changes to static resources are reflected in the browser; thus, the issue only affects CSHTML files
  • The old version of the file is served even after deleting or renaming the file; thus, a cache is most likely involved somewhere
  • Deleting the Temporary ASP.NET Files folder does not resolve the issue.
  • Recycling the app pool in IIS does not fix the issue.
  • Restarting the application in IIS does not fix the issue.
  • Restarting the IIS server does not fix the issue.
  • Disabling output caching does not fix the issue.
  • Though this problem is like this other problem, the solutions listed did not work.
  • This sounds similar but is not a long-term solution.
  • added 6/22/2023: re-deploying the application does not fix the issue

After each of these attempts, the server continued to serve the old CSHTML file.

答案1

得分: 0

解决方案
事实证明,管理员可以覆盖网页的内容,这样他们在需要进行语法或其他小改动时就不必开启工单。
每当对/cms/about路由发出请求时,应用程序会看到内容被覆盖,然后渲染它而不是/cms/about.aspx
我们通过修改覆盖的内容来解决了这个问题。

英文:

Solution

As it turns out, the admins can override the content of webpages so they don't have to open tickets when they need grammar- or other small changes.
Whenever requests were made to the /cms/about route, the app saw the content override, then rendered that instead of /cms/about.aspx.
We resolved the issue by modifying the overriding content.

huangapple
  • 本文由 发表于 2023年6月22日 02:17:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526103.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定