天天看點

配置iis,asp.net

今天配置iis和asp.net遇到伺服器錯誤,經過幾種嘗試辦法後,終于解決,是關于使用者權限的問題,執行兩條指令

C:/%WINDIR%/Microsoft.NET/Framework/v2.0.50727

aspnet_regiis -ga ASPNET

然後重新重新整理http://localhost/test.aspx頁面,即得到正确資訊.

test.aspx如下

<%@ page trace="true" %>

<html>

<head>

<title>A test page</title>

</head>

<body>

Hello - This is test.aspx

</body>

</html>

顯示結果

Hello - This is test.aspx

Request Details

Session Id: b2c14u55yb3vzfvsj3ajada1 Request Type: GET
Time of Request: 2006-8-11 15:25:02 Status Code: 200
Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)

Trace Information

Category Message From First(s) From Last(s)
aspx.page Begin PreInit
aspx.page End PreInit 3.57690393586893E-05 0.000036
aspx.page Begin Init 6.31246352527542E-05 0.000027
aspx.page End Init 9.06857427238519E-05 0.000028
aspx.page Begin InitComplete 0.000113728101738972 0.000023
aspx.page End InitComplete 0.000137645138075853 0.000024
aspx.page Begin PreLoad 0.000160547147721292 0.000023
aspx.page End PreLoad 0.000183539381961526 0.000023
aspx.page Begin Load 0.000206707052913861 0.000023
aspx.page End Load 0.00023099000010741 0.000024
aspx.page Begin LoadComplete 0.00026217512880277 0.000031
aspx.page End LoadComplete 0.000285836528787732 0.000024
aspx.page Begin PreRender 0.000308891418996574 0.000023
aspx.page End PreRender 0.000332868605063318 0.000024
aspx.page Begin PreRenderComplete 0.000355840789393598 0.000023
aspx.page End PreRenderComplete 0.000378775380142712 0.000023
aspx.page Begin SaveState 0.000817364654156955 0.000439
aspx.page End SaveState 0.000846216474581369 0.000029
aspx.page Begin SaveStateComplete 0.000869872862088843 0.000024
aspx.page End SaveStateComplete 0.000893236019663233 0.000023
aspx.page Begin Render 0.000916358578318171 0.000023
aspx.page End Render 0.00195655542546983 0.001040

Control Tree

Control UniqueID Type Render Size Bytes (including children) ViewState Size Bytes (excluding children) ControlState Size Bytes (excluding children)
__Page ASP.test_aspx 106
    ctl00 System.Web.UI.LiteralControl 106

Session State

Session Key Type Value

Application State

Application Key Type Value

Request Cookies Collection

Name Value Size

Response Cookies Collection

Name Value Size

Headers Collection

Name Value
Connection Keep-Alive
Accept ** HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:zh-cn HTTP_HOST:localhost HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
ALL_RAW Connection: Keep-Alive Accept: **
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE zh-cn
HTTP_HOST localhost
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

這裡再将錯誤資訊和其它解決方案一并貼出,

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the system event log of the web server. Please review this log entry to discover what caused this error to occur.

在域控制器或備份域控制器上安裝 Microsoft Visual Studio .NET 或 Microsoft .NET 架構後,如果您嘗試運作 ASP.NET 應用程式,則浏覽器會顯示下面的錯誤資訊:

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.

Please hit the "Refresh" button in your web browser to retry your request.

此外,系統應用程式事件日志中會記錄以下事件:

Failed to execute the request because the ASP.NET process identity does not have read permissions to the global assembly cache. Error: 0x80131902

aspnet_wp.exe  (PID: 4956) stopped unexpectedly

此問題涉及 Internet 資訊服務 (IIS) 5.0 版或更高版本。 

原因

預設情況下,為了提供更安全的環境,ASP.NET 用弱帳戶(名為 ASPNET 的本地計算機帳戶)運作它的輔助程序。域控制器或備份域控制器上的所有使用者帳戶都是域帳戶,不是本地計算機帳戶。是以,Aspnet_wp.exe 由于找不到名為"localmachinename/ASPNET"的本地帳戶而未能啟動。要在域控制器上提供有效的使用者帳戶,必須在 Machine.config 檔案的 <processModel> 部分指定顯式帳戶,或者必須使用 SYSTEM 帳戶。

改為<processModel userName="system" password="AutoGenerate"/>

備注:如果在嘗試浏覽頁面之前嘗試進行調試(單擊啟動按鈕),又出現完全相同的問題。 

解決方案

若要解決此問題,請使用下列方法之一:

建立具有正确權限的弱帳戶,然後配置 Machine.config 檔案的 <processModel> 部分使用該帳戶。

在 Machine.config 檔案的 <processModel> 部分,将 userName 屬性設為 SYSTEM。

配置 Machine.config 檔案的 <processModel> 部分使用管理者帳戶。 

備注:如果允許 ASP.NET 應用程式作為 SYSTEM 或管理者帳戶運作,将帶來嚴重的安全問題。如果使用其中的任一種變通解決辦法,在 Aspnet_wp.exe 程序中運作的代碼将能夠通路域控制器和域設定。從 Aspnet_wp.exe 程序啟動的可執行檔案在相同的上下文中運作,它們也能夠通路域控制器。

是以,Microsoft 建議使用第一種變通解決辦法。要使用第一種變通解決辦法,請執行以下步驟:

在計算機上建立名為 ASPUSER 的使用者帳戶,然後将此帳戶添加到"使用者組"中。

備注:如果更改了 .NET 架構建立的 ASPNET 帳戶的密碼,也可以使用該帳戶。您必須知道此帳戶的密碼,因為需要在後面的步驟中将該密碼添加到 <processModel> 部分。

向 ASPUSER 或 ASPNET 帳戶授予"作為批處理作業登入"的使用者權限。確定此更改在"本地安全政策"設定中顯示。

備注:要向此帳戶授予"作為批處理作業登入"的使用者權限,必須在以下每一個安全政策中授權此使用者權限(從"控制台"/"管理工具"開始操作):

域控制器安全政策

域安全政策

本地安全政策

備注:您必須重新啟動伺服器,以使這些更改生效。

確定 ASPUSER 或 ASPNET 帳戶具有的權限能夠通路啟動 Aspnet_wp.exe 程序和為 ASP.NET 頁提供服務所必需的全部目錄和檔案。有關必須向此帳戶授予哪些權限的其他資訊,請單擊下面的文章編号,檢視 Microsoft 知識庫中的文章: 

317012 INFO:ASP.NET 中的程序和請求辨別

打開 Machine.config 檔案。該檔案的路徑是:%Systemroot%/Microsoft.NET/Framework/v1.0.3705/CONFIG.

在 Machine.config 檔案的 <processModel> 部分,将 userName 和 password 屬性更改為第 1 步建立的帳戶的名稱和密碼。例如: userName="DomainName/ASPUSER" password="ASPUSERpassword"

儲存對 Machine.config 檔案所做的更改。 

繼續閱讀