【问题标题】:Couldn't save XML file using Server.MapPath无法使用 Server.MapPath 保存 XML 文件
【发布时间】:2013-11-21 02:36:50
【问题描述】:

我有一个简单的 asp 经典程序,可以在用户单击复选框时更新 xml 文件。它在我的开发服务器中运行良好,但是当我将它部署在我们的主服务器中时,它会显示一个

msxml3.dll 错误“80070005”访问被拒绝

(错误在 objXMLDoc.Save Server.MapPath(xmlfile) 中)。我已经检查了权限,它与我的开发服务器相同。

下面是xml文件

<notification>
<staff>
    <pin>P001</pin>
    <allow>1</allow>
</staff>
<staff>
    <pin>P002</pin>
    <allow>0</allow>
</staff>
</notification>

以及用于更新xml的asp经典代码

if Request.Form("updatebtn") = "Remove in Cc" then

    Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
    objXMLDoc.async = False
    objXMLDoc.load Server.MapPath(xmlfile)

    For Each xmlpin In objXMLDoc.documentElement.selectNodes("staff")

        pin = xmlpin.selectSingleNode("pin").text
        allow = xmlpin.selectSingleNode("allow").text

        if allow = 1 then

            if Request.Form("chk_" & pin) = "on" then

                Response.Write(pin & "<br/>")

                Set nodeBook = xmlpin.selectSingleNode("allow")
                nodeBook.Text = 0
                objXMLDoc.Save Server.MapPath(xmlfile) ' error when saving the xml 

            end if

        end if

    next

    Response.Redirect("notification.asp")

end if

有没有我忽略的设置?

非常感谢您的帮助

【问题讨论】:

  • 权限一样,但是IIS使用的账号是一样的吗?
  • 您的 iusr 帐户似乎没有使用 msxml3.dll 本身的权限。现在有更新版本的 msxml - 试试 Server.CreateObject("MSXML2.DOMDocument.6.0")

标签: xml asp-classic


【解决方案1】:
  1. 您必须检查运行站点的 IIS 应用程序池使用了哪个用户(可能是 IUSR_xy)。

  2. 确保此用户在您保存 XML 文件的文件夹中具有“覆盖”权限(在文件夹安全设置中)。

我曾经遇到过问题,我的应用程序可以创建一个新文件,但由于这个原因无法覆盖它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-02
    • 2011-07-15
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    相关资源
    最近更新 更多