当前位置:编程学习 > asp >>

微软ASP.NET站点部署指南(12):Troubleshooting

这个页面列出的是Visual Studio 部署ASP.NET 程序时经常出现的问题。对于每个错误,都列出了可能出错的原因和解决方案。

 

使用SQL Server Compact时,页面出现Access is Denied

场景

使用SQL Server Compact数据库部署站点以后,运行页面出现如下错误:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

 

产生原因和解决方案

服务器上的NETWORK SERVICE账户需要读取SQL Service Compact原生库(\amd64或bin\x86目录)的权限,但没有读取该文件夹的权限。查看前面的章节如何给bin目录授权(确保子目录也有相同的权限)。

 

因权限不够不能读取配置文件

场景

使用Visual Studio发布按钮部署程序的时候,Output窗口出现如下错误信息:

An error occurred when reading the IIS Configuration File 'MACHINE/REDIRECTION'. The identity performing this operation was ... Error: Cannot read configuration file due to insufficient permissions.

 

产生原因和解决方案

使用one-click发布,必须使用管理员身份运行Visual Studio。关闭Visual Studio,以管理员身份重新运行Visual Studio。

 

不能连接到目标服务器

场景

使用Visual Studio发布按钮部署程序的时候,Output窗口出现如下错误信息:

Web deployment task failed.(Could not connect to the destination computer ("<server URL>") using the specified process

("The Web Management Service"). This can happen if a proxy server is interrupting communication with the destination server.

Disable the proxy server and try again.) ... The remote server returned an error: (502) Bad Gateway.

 

产生原因和解决方案

有可能是代理服务器问题,解决方法:打开控制面板或者Internet选项,选择连接选项卡,在Internet属性对话框里点击局域网设置,在局域网(LAN)设置对话框里在取消自动检测设置。然后重新发布。

如果问题依旧,联系你的管理员看看关于代理和防火墙可以做什么修改,因为Web Deploy为Web Management Service使用不标准的端口(8172),其它的连接Web Deploy 使用的是80端口。部署到第三方主机的时候一般使用的是Web Management Service。

 

默认.Net应用程序池不存在

场景

部署.NET Framework 4程序的时候,出现如下错误信息:

The default .NET 4.0 application pool does not exist or the application could not be added. Please verify that ASP.NET 4.0 is installed on this machine.

 

产生原因和解决方案

IIS上没有安装ASP.NET4,如果部署的服务器是你的开发机(安装了VS2010),ASP.NET4已经安装在服务器上了,但是没有安装在IIS上。要想成功部署,需要在Command Prompt窗口里运行如下命令在IIS里安装ASP.NET4:

	cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regiis.exe –iru

你还要为默认应用程序池设置.NET framework版本,具体步骤请参考第5章。

 

Format of the initialization string does not conform to specification starting at index 0

场景

使用one-click发布以后,访问页面(需要读取数据库)的时候出现如下错误:

Format of the initialization string does not conform to specification starting at index 0.

 

产生原因和解决方案

打开部署站点的Web.config文件,看看数据库连接字符串是不是以$(ReplacableToken_开头,像下面这样:

	<connectionStrings>
  <add name="DefaultConnection" connectionString="$(ReplacableToken_DefaultConnection-Web.config Connection String_0)" providerName="System.Data.SqlServerCe.4.0"/>
  <add name="SchoolContext" connectionString="$(ReplacableToken_SchoolContext-Web.config Connection String_0)" providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

 

如果是和上面一样,需要编辑项目文件,在PropertyGroup里添加如下属性:

	<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>

 

然后重新部署

 

HTTP 500.21 Internal Server Error

场景

运行部署以后的站点,出现如下错误信息:

HTTP Error 500.21 - Internal Server Error. Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list.

 

产生原因和解决方案

程序需要ASP.NET4,但是IIS上没有注册ASP.NET4,注册ASP.NET4请在Command Prompt里运行如下代码:

	cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regiis.exe –iru

你还要为默认应用程序池设置.NET framework版本,具体步骤请参考第5章。

 

不能打开App_Data目录下的SQL Server Express数据库

场景

为连接App_Data目录下的SQL Server Express数据库(.mdf文件),Web.config设置了连接字符串,第一次运行程序的时候出现如下错误:

System.Data.SqlClient.SqlException: Cannot open database "DatabaseName" requested by the login. The login failed.

 

产生原因和解决方案

在服务器上找不到任何叫该名称的SQL Server Express数据库(即便是以前删过同名的文件了,也不行),解决方案是给这个.mdf文件重命名一个从来没用过的名字,然后修改Web.config文件里的连接字符串。

 

 

Model Compatibility Cannot be Checked

场景

为连接App_Data目录下的SQL Server Express数据库(.mdf文件),Web.config设置了连接字符串,第一次运行程序的时候出现如下错误:

Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

 

产生原因和解决方案

现有的数据库名字,曾经在本机存在,里面可能有表和数据,如果你有SQL Server Management Studio (SSMS)的话,可以通过它来删除,如果没有请问你的数据库取一个没用过的名字,然后修改Web.config文件里的连接字符串。

 

创建User和Role的时候出现SQL Error

场景

支持该脚本的时候失败,出现如下错误:

The approximate location of the error was between lines '1' and '3' of the script.

The verbose log may have more information about the error. The command started with:

CREATE USER [user2] FOR LOGIN [user2] WITH DEFAULT

Error: User does not have permission to perform this action.

 

产生原因和解决方案

运行SQL脚本的账户没有权限,一般提供商会给db_datareader, db_datawriter和 db_ddladmin角色,虽然可以创建大部分数据库对象,但是不能创建User和Role。要避免这个问题需要在数据库自动生成脚本的ProSource元素里添加如下属性:

	CopyAllUsers=false, CopyAllRoles=false

如何编辑项目文件里的PreSource元素。请参看:Edit Deployment Settings in the Project File。如果你开发库里的User和Role需要部署在目标库,请联系你的提供商。

 

部署运行自定义脚本的时候出现SQL超时错误

场景

运行自定义脚本的时候出现超时错误:

 

产生原因和解决方案

在不同的事务里运行多个脚本的,默认情况下自动生成的脚本在一个事务,但是自定义脚本不在,如果你选择了Package/Publish SQL选项卡上的Pull data and/or schema from an existing database并且添加自定义SQL脚本的话,你必须在一些脚本上做一些事务的设置。详细信息请参考: How to: Deploy a Database With a Web Application Project。

 

Stream Data of Site Manifest Is Not Yet Available

场景

使用deploy.cmd文件在t(Test)选项下安装package的时候,出现如下错误:

Error: The stream data of 'sitemanifest/dbFullSql[@path='C:\TEMP\AdventureWorksGrant.sql']/sqlScript' is not yet available.

 

产生原因和解决方案

该命令不能产生test report,如果在命令行输入y选项的话,可能没问题。注:该错误信息只在Test模式下才会出现。

 

补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,