English 中文(简体)
How do I modify the custom errors of a remote IIS6 website using MSBuild
原标题:

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 SubErrorCode value of "*":

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

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.

问题回答

暂无回答




相关问题
Enabling Ant Tools in a new Eclipse Galileo installation

I have recently installed Eclipse Galileo with the PHP Developers Tools. I plan to install the Flash Builder 4 Plug-in to do ActionScript development as well. I want to use Eclipse to both create an ...

Continuous Integration with Teamcity and Clearcase

Has anybody successfully integrated Clearcase with Teamcity (which advertises Clearcase support) to realize a productive continuous integration build environment on a decent size project?

热门标签