ASP.NET on IIS 7
要在新裝好的Widows Vista上跑Community Server,發現Vista搭配的IIS 7,管理介面已大幅修改,花了點功夫才找到對應的設定處。
設好IIS Home Directory後遇到的第一個問題是IIS回應不支援ASP.NET,用控制台的"Programs and Features"(就是以前的"新增/移除軟體")檢查了一下,才發現原先啟用IIS時直接套用了它的預設安裝選項,其中並不包含ASP.NET, ASP, ISAPI... 等等,要跑程式的人得另外勾選。(這很符合給"一般使用者"使用的OS定位,基於安全考量,不常用的功能預設一律關閉,看來Programmer要用Vista,少不了要披荊斬棘)
啟用了ASP.NET,接著IIS又回報錯誤:
Server Error in Application "Default Web Site"
HTTP Error 500.0 - Internal Server Error
Description: This application is running in an application pool that uses the Integrated .NET mode. This is the preferred mode for running ASP.NET applications on the current and future version of IIS.
In this mode, the application should not specify ASP.NET module components in the <system.web>/<httpModules> configuration section. Instead, it should use the <system.webServer>/<modules> configuration section to load ASP.NET module components. You have the following options:
1) Migrate the application to work with the Integrated .NET mode (PREFERRED).
You can migrate the application configuration, including the contents of the <httpModules> configuration section, by using the following from a command line window (the window must be running as Administrator):
%systemroot%\system32\inetsrv\APPCMD.EXE migrate config "Default Web Site/"
After you migrate your application, it will run in both Classic and Integrated .NET modes, as well as on downlevel platforms. 2) Move this application to an application pool using the Classic .NET mode.
You can move the application to the default application pool using the Classic .NET mode by running the following from an command line window (the window must be running as Administrator):
%systemroot%\system32\inetsrv\APPCMD.EXE set app "Default Web Site/" /applicationPool:"Classic .NET AppPool"
Alternatively, you can use any other application pool on your system that is running in the Classic .NET mode. You can also use the IIS Administration tool to move this application to another application pool.
It is preferred that you migrate this application by using option 1 to take advantage of the benefits provided by the Integrated .NET mode.
Windows Vista在設計概念的一項重大變革是出錯時會提供更詳盡的訊息與指示,以上的錯誤訊息就是不錯的範例。訊息說明了原因,連用什麼指令可以解決也一併寫出來,十分貼心。
由以上的訊息得知,應是Community Server用了HttpModule及HttpHandler,而IIS 7多了Integrated .NET Mode的概念,因此web.config需要調整。開了個CMD.EXE,跑了appcmd.exe,卻遇到了以下的錯誤:
D:\Blog\Source\Web>%systemroot%\system32\inetsrv\appcmd.exe migrate config "Default Web Site/"
ERROR ( message:Configuration error
Filename: \\?\C:\Windows\system32inetsrv\config\applicationHost.config
Line Number: 0
Description: Cannot read configuration file
. )
Google了一下,找到了相關的說明,原來這次是Windows Vista的安全管控發威,我們得用Run As Administrator來跑這段指令。Migrate完成,Community Server在IIS 7上跑將起來,yahoo~~