2009-12-15 45 views
1

我試圖使用「Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting」更改遠程IIS網站的http錯誤消息。這項任務的文檔特別有些缺乏,我還沒有找到成功使用它的方法。我想要HTTP 404錯誤來加載一個URL而不是默認的404b.html文件。我使用任務這樣嘗試:如何使用MSBuild修改遠程IIS6網站的自定義錯誤

<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() 

進一步的深入瞭解是非常受歡迎。

回答

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。

相關問題