1

我正在尝试使用“Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting”来更改远程 IIS 网站的 http 错误消息。特别是这项任务的文档有些缺乏,我还没有找到成功使用它的方法。我希望 http 404 错误加载一个 url 而不是默认的 404b.html 文件。我试过这样使用任务:

<Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting
  ErrorCode="404"
  MachineName="$(MachineName)"
  WebSiteName="$(SiteName)"
  Path="."
  Uri="/errors/mycustom404.htm"
  Type="URL"
  DirectoryType="WebDir" />

任务运行时出现异常,但我不清楚我缺少什么:

Using "Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting" task from assembly "c:\Microsoft.Sdc.Tasks.dll".
Task "Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting"
 error : A task error has occured.
 error : Message       = Object reference not set to an instance of an object.
 error : ErrorCode     = 404
 error : SubErrorCode  = <String.Empty>
 error : Uri           = /errors/mycustom404.htm
 error : Type          = URL
 error : DirectoryType = WebDir
 error : MachineName   = testMachineName
 error : WebSiteName   = testSiteName
 error : Path          = .
 error : DirectoryName = <String.Empty>
 error : 
 error :    at Microsoft.Sdc.Tasks.Web.WebSite.UpdateHttpErrorSetting.InternalExecute()

非常欢迎进一步的见解。

4

1 回答 1

0

正如我想象的那样,我对任务的使用是不正确的。像 404 这样的顶级 HTTP 错误要求您指定以下SubErrorCode"*"

<Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting
  ErrorCode="404"
  SubErrorCode="*"
  MachineName="$(MachineName)"
  WebSiteName="$(SiteName)"
  Path="."
  Uri="/errors/mycustom404.htm"
  Type="URL"
  DirectoryType="WebDir" />

这实际上是在 SubErrorCode 属性的文档中。

如果未指定或不正确,则空引用是由任务在机器的 http 错误集合上执行的查找引起的。没有检查返回的 null。

于 2009-12-17T12:21:23.917 回答