Windows 2012 安装IIS8 ASP.NET 的复杂过程

[ 2018-08-09 13:16:58 | 作者: admin ]
字号: | |
p.s. 下面的文章和我遇到的情况一模一样,心路历程也一样。我只想说,微软的产品真的不够人性化。

文章来源:http://blog.darkthread.net/post-2013-11-29-iis8-asp-net-setup.aspx

專案動用了SignalR 2.0,在我的Windows 2008R2開發機配合Chrome實測卻怎麼都無法開啟WebSocket傳輸,後來才發現SignalR支援WebSocket的必要條件:

        伺服器端: .NET 4.5 Framework + Windows 8 或 Windows 2012
        瀏覽器端: IE10+或其他瀏覽器

為上線預做準備,決定灌台Windows 2012R2 VM演練兼實測。Windows 2012R2介面修改不小,融入許多Windows 8風格,所幸Roles、Feature等觀念仍與Win2008一致,只差得花點時間熟悉新操作介面。

新增了IIS,也勾選了ASP.NET 4.5,心想這樣ASP.NET就安裝完成了。
attachments/201808/09_131751_1980658ao.gif


在IIS管理工具使用Add Application掛上ASP.NET程式,但IIS管理員看起來怪怪的,右方只有IIS區,少了ASP.NET區。
attachments/201808/09_131810_19837711o.gif


瀏覽ASP.NET網頁,得到500.19錯誤:

        HTTP Error 500.19 - Internal Server Error
        The requested page cannot be accessed because the related configuration data for the page is invalid.
        Error Code 0x80070021
        Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
attachments/201808/09_131828_1979a932o.gif


依據過去的知識(參考: 91的文章),常是aspnet_regiis未正確註冊所致,試著註冊卻有新發現:

        C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
        Microsoft (R) ASP.NET RegIIS version 4.0.30319.33440
        Administration utility to install and uninstall ASP.NET on the local machine.
        Copyright (C) Microsoft Corporation. All rights reserved.
        Start installing ASP.NET (4.0.30319.33440).
        This option is not supported on this version of the operating system. Administr
        ators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win
        dows Features On/Off" dialog, the Server Manager management tool, or the dism.e
        xe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.
        Finished installing ASP.NET (4.0.30319.33440).

ASP.NET 4.5跟IIS8已不用aspnet_regiis這招了,要透過Feature管理新增才行,但是如第一張圖例所示,我明明已經裝過ASP.NET 4.5呀?

摸索了一陣子才搞懂,我在新增Role時少選了Application Server項目:
attachments/201808/09_131854_1981a1d9o.gif


Application Role有個Web Server (IIS) Support,記得也要安裝。
attachments/201808/09_131918_1.gif


加入Web Server (IIS) Support後,Web Server區會多出Application Developer項目,下面有ASP、ASP.NET 3.5、CGI... 等子項可以選擇。如果想啟用SignalR WebSocket傳輸,記得要勾選WebSocket Protocol。
attachments/201808/09_131934_2.gif


幾經波折,WebSocket + SignalR終於合體完成!

【延伸閱讀】附上官方版的IIS8 ASP.NET安裝步驟。https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45
[最后修改由 admin, 于 2018-08-09 13:21:27]
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2523

这篇日志没有评论。

此日志不可发表评论。