如何使用 WiX 在 IIS7.5 中设置自定义错误 URL

发布于 2024-12-20 01:05:49 字数 1486 浏览 0 评论 0原文

我的第一个问题所以请友善。我的安装程序出现问题,这是安装程序日志中的错误。

MSI (s) (4C:64) [14:56:14:086]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI6E35.tmp, Entrypoint: WriteIIS7ConfigChanges
CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 14:56:15: InstallFinalize. Return value 3.

安装程序因错误退出并回滚。通过反复试验,我发现了 IIS 配置的问题,并将其范围缩小到自定义错误页面的设置(下面的示例),

<iis:WebSite Id="myWebService1" Description="myWebService" AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes" Directory="WEBAPPDIR" ConnectionTimeout="360" >
    <iis:WebAddress Id="myWebService_Bindings" IP="*" Port="9992" />
    <iis:WebApplication Id="myWebService" Name="myWebService" WebAppPool="myWebService_Pool" ScriptTimeout="360" />
    <iis:WebDirProperties Id="myWebService_Properties" AnonymousAccess="yes" WindowsAuthentication="no" DefaultDocuments="Default.ashx" Read="yes" Execute="yes" Script="yes" />
    <iis:WebVirtualDir Id="myWebService_Download" Alias="download" Directory="FILEDOWNLOADDIR">
        <iis:WebError ErrorCode="404" URL="/dostuff.ashx" SubCode="0"/>
    </iis:WebVirtualDir>
</iis:WebSite>

我认为可能存在覆盖默认自定义错误页面的问题,因为它们是继承的,尽管似乎有在IIS6中就没有这样的问题了。我预计 WiX 的默认行为只是覆盖已经存在的内容,但情况似乎并非如此。我还尝试通过将包含自定义错误所需 xml 的 web.config 复制到下载文件夹来解决此问题,但当我尝试查看“错误页面”列表时,我在 IIS 中也遇到了冲突。

我非常感谢对此的帮助。

My first question so please be kind. I am having problems with my installer here is the error from the installer log.

MSI (s) (4C:64) [14:56:14:086]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI6E35.tmp, Entrypoint: WriteIIS7ConfigChanges
CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 14:56:15: InstallFinalize. Return value 3.

The installer quits with an error and rolls back. Through trial and error I have found the problem with the IIS configuration and have narrowed it down to the setup of the custom error page (example below)

<iis:WebSite Id="myWebService1" Description="myWebService" AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes" Directory="WEBAPPDIR" ConnectionTimeout="360" >
    <iis:WebAddress Id="myWebService_Bindings" IP="*" Port="9992" />
    <iis:WebApplication Id="myWebService" Name="myWebService" WebAppPool="myWebService_Pool" ScriptTimeout="360" />
    <iis:WebDirProperties Id="myWebService_Properties" AnonymousAccess="yes" WindowsAuthentication="no" DefaultDocuments="Default.ashx" Read="yes" Execute="yes" Script="yes" />
    <iis:WebVirtualDir Id="myWebService_Download" Alias="download" Directory="FILEDOWNLOADDIR">
        <iis:WebError ErrorCode="404" URL="/dostuff.ashx" SubCode="0"/>
    </iis:WebVirtualDir>
</iis:WebSite>

I think there might be an issue overwriting the default custom error pages as they are inherited although there seems to be no such problem in IIS6. I would expect the default behaviour of WiX would be to just overwrite what was already there but does not seem to be the case. I have also tried to get around this by copying a web.config with the necessary xml for the custom error to the download folder but I also get a conflict in IIS when I try to view the "Error pages" list.

I would greatly appreciate some help with this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人海汹涌 2024-12-27 01:05:49

我遇到了完全相同的事情。我在此处找到了答案。

它在 web.config 文件中的处理如下:

<system.webServer>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="filePath.aspx" responseMode="ExecuteURL"/>
    </httpErrors>

I was running into the exact same thing. I found an answer for it here.

It's handled in the web.config file like this:

<system.webServer>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="filePath.aspx" responseMode="ExecuteURL"/>
    </httpErrors>
暖树树初阳… 2024-12-27 01:05:49

因此,为了解决这个问题,我需要创建自定义操作并以编程方式添加 HttpError。我在下面提供了一个方法来实现这一点。我最初很难让这个工作正常,因为在添加我自己的错误代码之前我没有删除现有的继承错误代码

private static void ConfigureHTTPError(long _ErrorCode, string _URL, string _SubCode, System.DirectoryServices.DirectoryEntry VDir)
{
    string searcherr = _ErrorCode.ToString() + "," + _SubCode;
    string customerr = searcherr + ",URL," + _URL;

    for (var i = 0; i < VDir.Properties["HttpErrors"].Count; i++)
    {
        if (VDir.Properties["HttpErrors"][i].ToString().IndexOf(searcherr) == 0)
        {
            //must remove the existing error code first
            VDir.Properties["HttpErrors"].RemoveAt(i);
            VDir.CommitChanges();
            VDir.Properties["HttpErrors"].Add(customerr);
            VDir.CommitChanges();
        }
    }
}

希望如果您遇到同样的问题这会有所帮助。我有更多关于此的代码,因此如果您需要帮助,请询问。

So to get around this issue I needed to create custom action and programmatically add the HttpError. I have included a method below that does it. I initially struggled to get this working because I didn't remove the existing inherited error code before adding my own one

private static void ConfigureHTTPError(long _ErrorCode, string _URL, string _SubCode, System.DirectoryServices.DirectoryEntry VDir)
{
    string searcherr = _ErrorCode.ToString() + "," + _SubCode;
    string customerr = searcherr + ",URL," + _URL;

    for (var i = 0; i < VDir.Properties["HttpErrors"].Count; i++)
    {
        if (VDir.Properties["HttpErrors"][i].ToString().IndexOf(searcherr) == 0)
        {
            //must remove the existing error code first
            VDir.Properties["HttpErrors"].RemoveAt(i);
            VDir.CommitChanges();
            VDir.Properties["HttpErrors"].Add(customerr);
            VDir.CommitChanges();
        }
    }
}

Hope this helps if you come across the same issue. I have more code around this so if you need help just ask.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文