如何在 windows 10 上使用 IIS8 注册 .Net 4.5.1

How to register .Net 4.5.1 with IIS8 on windows 10

如何在 windows10 机器上用 IIS8 注册 .Net 4.5.1? 它曾经像 运行ning 命令 "aspnet_regiis -i" 一样简单...但现在不是了。如果尝试 运行 这个命令我得到错误

This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771. Finished installing ASP.NET (4.0.30319.0).

也在 windows 10 下 "Turn windows feature on & off" windows 为什么我看不到 .net 4.5 或 4.5.1?不过我确实看到了 4.6。和4.5.1一样吗?
(请注意,我确定我的机器上安装了 4.5.1,因为 visual studio 允许我在 Web 应用程序上设置目标框架 4.5.1,并且我有几个应用程序 运行s 在 4.5.1 上没有任何问题)

i do see 4.6 though. Is it same as 4.5.1?

.NET 4.6 是 4.5.1 的替代品。也就是说,您的 4.5.1 应用程序将在 4.6 上 运行。所以你可以说 4.6 "includes" 4.5.1.

您可以使用 dism 工具启用 Windows 中内置的功能。要在 IIS 中安装 .NET 4.5(或 4.6,它们是相同的,因为它在下面是相同的 CLR4),我认为这可行:

dism /online /enable-feature /featurename:IIS-ASPNET45 /all

/all 标志将包含任何依赖项,因此您不必全部弄清楚。

您还可以通过 运行 查看所有可用功能:

dism /online /get-features

顺便说一句,当您需要将某个版本的 CLR 安装到 IIS 中时,使用了 aspnet_regiis。由于自 4.0 以来的所有 .NET 版本都使用相同的 CLR 版本,因此现在已将其内置到 Windows 功能中。因此,您改用 DISM 来启用该功能。

如果您 ASP.NET 版本不可知并且只想要 ASP.NET 状态服务 运行ning,转到 IIS -> Web 服务器 (IIS) -> Web 服务器 ->应用程序开发并选择最新的 ASP.NET。这将在 Services.msc 中创建 ASP.NET 状态服务,然后您可以将其配置为 运行.