寫ASP.NET程序已經有幾年了,可是每每將網站或者Web應用程序部署到IIS上的時候,還總是出錯。每次都需要查看錯誤信息,甚至搜索網絡找到處理方法,於是這一次來了個全程記錄,把步驟和遇到的問題都記下來,與同道共享:)
1、在IIS中創建虛擬目錄(WebSite)或者應用程序(WebApp);
注意:發布的程序必須創建應用程序,否則出錯如下:
Parser Error Message: Could not load the assembly 'App_Web_nqebt6fg'. Make sure that it is compiled before accessing the page.
Source Error:
Line 1: <%@ page language="C#" autoeventwireup="true" inherits="_Default, App_Web_nqebt6fg" %>
|
2、給IIS_IUSRS和IUSR賦予虛擬目錄讀寫權限,否則出錯如下:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
3、設置“認證”屬性,啟用“仿冒”,否則出錯如下:
HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
4、設置應用程序池為“經典模式”(如果需要的話),否則出錯如下:
HTTP Error 500.24 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
5、在連接字符串中不要使用集成安全,而是使用用戶名/密碼(如果不是Windows認證的話),否則出錯如下:
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\IUSR'.
6、
7、
8、