简体   繁体   English

Windows April更新后,我的应用程序退出了提供静态文件的过程

[英]My app quits serving static files after the Windows April Update

I have an app where the Content folder is filled by another process that builds a frontend app, and the Visual Studio project itself doesn't know what's in the folder. 我有一个应用程序,其中Content文件夹由另一个构建前端应用程序的进程填充,而Visual Studio项目本身不知道文件夹中的内容。 I set up the web.config with a standard <staticContent> node and <modules runAllManagedModulesForAllRequests="true"> . 我使用标准的<staticContent>节点和<modules runAllManagedModulesForAllRequests="true">设置了web.config。 I have my RouteConfig set up with routes.IgnoreRoute("content/*"); 我用routes.IgnoreRoute("content/*");设置了我的RouteConfig routes.IgnoreRoute("content/*");

The app typically runs with IIS Express, but I have also run it with IIS proper. 该应用程序通常与IIS Express一起运行,但我也已与IIS一起运行它。

This has all worked fine to load js, css, and other static files directly from the content folder. 直接从内容文件夹中加载js,css和其他静态文件的所有方法都工作良好。 That is, up until I installed the Windows April update. 也就是说,直到安装Windows April更新为止。 Now every single static file request results in a 404. If I attempt to go to the physical path requested (but going through Exporer), I get the file. 现在,每个单个静态文件请求都生成404。如果我尝试转到请求的物理路径(但通过Exporer),则会得到文件。 The files are there. 文件在那里。 The app works on Azure when I deploy it, so it must be something local. 部署该应用程序时,它可以在Azure上运行,因此它必须是本地的。

Here's what I've tried: 这是我尝试过的:

  • Uninstalling both IIS Manager and IIS Express, removing the appPools from c:\\inetpub\\temp\\appPools and reinstalling IIS Express. 卸载IIS管理器和IIS Express,从c:\\inetpub\\temp\\appPools然后重新安装IIS Express。
  • Removing the staticContent node and setting runAllManagedModulesForAllRequests to false. 除去staticContent节点,并将runAllManagedModulesForAllRequests设置为false。
  • Giving full access to "Everybody" in the project folder and subfolders. 授予对项目文件夹和子文件夹中的“所有人”的完全访问权限。
  • Turning off UAC. 关闭UAC。

What could it be? 会是什么呢? I'm at a loss as to how to continue working after the Windows Update. 我对Windows Update之后如何继续工作一无所知。

It appears that the update process corrupted my IIS installation in some way. 似乎更新过程以某种方式破坏了我的IIS安装。 I performed a Windows Refresh, installed all my tools and pulled down my app and it works just fine. 我执行了Windows Refresh,安装了所有工具,然后关闭了我的应用程序,一切正常。

\n

Hardly a quick or easy fix, but I was up and running again after a few hours. 很难快速或轻松地解决,但几个小时后我又重新启动并运行。

I found the actual problem and how to fix it. 我发现了实际问题以及解决方法。

The Windows April Update added a nifty feature where you can set case sensitivity on or off for specific folders. Windows April Update添加了一个漂亮的功能,您可以在其中打开或关闭特定文件夹的区分大小写。 They also made it so that any folder created using the Linux Subsystem has case sensitivity turned on by default. 他们还做到了这一点,以使使用Linux子系统创建的所有文件夹默认情况下都区分大小写。 Doing the same with cmd.exe or powershell.exe has case sensitivity off by default. 默认情况下,使用cmd.exe或powershell.exe进行相同操作将区分大小写。

My app has the client portion built using node/webpack and put into the Content folder of the .Net application. 我的应用程序具有使用node / webpack构建的客户端部分,并将其放入.Net应用程序的Content文件夹中。 When I did a Windows Refresh, I initially had built my app with cmd.exe and it worked fine. 当我执行Windows Refresh时,最初使用cmd.exe构建了我的应用程序,并且运行良好。 After I turned on the Linux Subsystem and built the app with bash, I started getting 404s on all of the files in the Content folder again. 打开Linux子系统并使用bash构建应用程序后,我又开始在Content文件夹中的所有文件上获取404。 ProcMon.exe was telling me that the files that were failing were in uppercase (ie, if the file is modernizr.min.js, IIS was trying to open MODERNIZR.MIN.JS). ProcMon.exe告诉我失败的文件是大写的(即,如果文件是modernizr.min.js,则IIS试图打开MODERNIZR.MIN.JS)。 I'm not sure why IIS was trying to load a file in all caps, other that the fact that when IIS caches a file, it uses all caps. 我不知道为什么IIS试图以大写形式加载文件,除了IIS缓存文件时,它使用所有大写形式。

SOME SOLUTIONS 一些解决方案

Option #1: Don't use the Linux Subsystem or Case Sensitive folders. 选项#1:不要使用Linux子系统或区分大小写的文件夹。

This problem seems to only happen when IIS is serving files from a folder with case sensitivity enabled, which happens by default with folders created in the Linux Subsystem. 仅当IIS从启用了区分大小写的文件夹提供文件时才出现此问题,默认情况下,这种情况发生在Linux子系统中创建的文件夹中。

Option #2: Set the Windows default for the Linux Subsystem to use case insensitivity. 选项2:将Linux子系统的Windows默认设置为不区分大小写。

Edit /etc/wsl.conf (create if it doesn't exist) and add the following: 编辑/etc/wsl.conf(如果不存在,则创建)并添加以下内容:

[automount]
options="case=off"

You will need to exit the terminal and start it again for the changes to occur. 您将需要退出终端,然后再次启动它,以进行更改。 Any folders previously created in bash will need to have their flags set, or be deleted and recreated. 以前在bash中创建的所有文件夹都需要设置其标志,或者将其删除并重新创建。

Option #3: Update each folder's case sensitivity flag. 选项#3:更新每个文件夹的区分大小写标志。

This could be added as part of the build script or done by hand if you don't need to repeatedly do it. 这可以作为构建脚本的一部分添加,或者如果您不需要重复执行,则可以手动完成。 You'll need to set the execution policy to be able to run powershell scripts first. 您需要将执行策略设置为能够首先运行Powershell脚本。

Set-ExecutionPolicy remoteSigned

Powershell Script (FixFolders.ps1): Powershell脚本(FixFolders.ps1):

param (
    [string]$root = $( Get-Location )
)

if ( Test-Path $root ) {

    $rootPath = $( Get-Item -Path $root )

    fsutil file setCaseSensitiveInfo $rootPath disable
    foreach ($path in Get-ChildItem -Path $rootPath -Directory -Recurse) {
        fsutil file setCaseSensitiveInfo $path.FullName disable
    }
}

This script will disable case sensitivity on the specified folder (or current folder) and all subfolders. 该脚本将在指定的文件夹(或当前文件夹)和所有子文件夹上禁用区分大小写。

FixFolders.ps1 will run on the current folder and all subfolders. FixFolders.ps1将在当前文件夹和所有子文件夹上运行。

FixFolders.ps1 c:\\dev will run on c:\\dev and all subfolders. FixFolders.ps1 c:\\dev将在c:\\ dev和所有子文件夹上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM