I’m trying to use “Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting” to change the http error messages of a remote IIS website. The documentation for this task in particular is somewhat lacking and I haven’t found a way to use it succesfully. I’d like the http 404 error to load a url instead of the default 404b.html file. I’ve tried using the task as such:
<Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting
ErrorCode="404"
MachineName="$(MachineName)"
WebSiteName="$(SiteName)"
Path="."
Uri="/errors/mycustom404.htm"
Type="URL"
DirectoryType="WebDir" />
I get an exception when the task runs but I’m not clear on what I’m missing:
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()
Further insight is very welcome.
As I imagined, my usage of the task was incorrect. Top level HTTP errors like 404 require you to specify a
SubErrorCodevalue of"*":This is actually in the documentation for the SubErrorCode property.
If this is not specified, or incorrect, a null reference is caused by a look-up that the task performs on the machine’s http errors collection. There is no check on the returned null.