要在新裝好的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~~


Comments

# by Calvin

你好: 我搞了好久,問題還是一樣出現HTTP Error 500.0 - Internal Server Error 請問該如何設定?才能夠執行ASP~!??

# by Jeffrey

單就HTTP 500很難推斷問題的所在,所有ASP/ASP.NET程式發生錯誤都算在500的頭上,此時細部的錯誤訊息比較能夠提供解決問題的線索(如這篇文章中的示範)。看你要不要提供更詳細一點的資訊,大家可以幫你看看。 討論區可以寫比較長的文字,有需要也可在那裡提問。(連結請見"關於作者")

# by John

我也是裝又拆,拆了又裝,問題依然存在 HTTP 500... 快撞牆了哦!哈!苦中作樂一下,請問有人知道為什麼嗎?

# by Leo

我也碰到了同样问题 ,可还是不能解决; 运行appcmd命令后,出现以下Error: Configuration error cannot add duplicate collection entry 问题出在哪里呢,谁知道啊?

# by fire

如果是虚拟主机上出现500错误怎么办?不给我直接在服务器上操作

# by fg

500 的錯誤要先把show friendly html error massages 鉤調才看得到

# by 阿宅

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Unrecognized attribute 'type'. Source Error: Line 10: <configuration> Line 11: <configSections> Line 12: <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> Line 13: <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> Line 14: <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/> 我是line 12顯示紅色錯誤,有人知道怎麼解決嗎?

# by Jeffrey

to 阿宅,IIS上沒有把WebApplication切換成ASP.NET 2.0?

Post a comment