新闻资讯 >> 文档资料 >> 网络技术 >> 传统ASP程序开发者使用IIS7的小提示
  • 传统ASP程序开发者使用IIS7的小提示

  • 刊发日期:2007-5-22 (16年前)    本文作者:疾风之狼    刊发部门:岭峰网    阅读次数:14752
  • 使用传统ASP编程的开发人员应该对IIS7的几个小变化引起注意。



    ASP缺省不安装


    重要的事先来! 如果从XP迁移到Vista / Longhorn Server, 您也许会得到这个错误:
    --------------------------------------------------------------------------------------------------------------------

    HTTP Error 404.3 - Not Found

    Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.

    --------------------------------------------------------------------------------------------------------------------
    这是您没有安装ASP组件时的情形,所以去您安装IIS的地方找到IIS/WWW Services(WWW服务)/Application Development(应用程序开发)/ASP 来安装它。:)


    Access 与传统ASP


    很多人使用Access作为数据库-因为它小巧,可复制, 容易处理。我们在Vista IIS7的一个变动就是缺省不使用ASP和Access。本篇我将详细描述这一变化, 但根本上这是因为应用程序池(Application Pool)缺省不再使用\windows\temp, 而改为应用程序池身份档案(identity's profile)和临时目录。并且因为只有
    网络服务
    才能向网络服务的临时目录执行写入操作, ASP使用虚拟身份(impersonated identity)访问数据库, 所以匿名或已认证的ASP应用程序就会中止。如果您在IIS7使用ASP+Access、你大概会看到与以下提示类似的错误信息:
    --------------------------------------------------------------------------------------------------------------------

    Microsoft JET Database Engine error '80004005'
    Unspecified error

    --------------------------------------------------------------------------------------------------------------------
    回答很简单: 关闭loadUserProfile, 或者设置temp directory的访问权限以允许写操作. 这一问题和其它兼容性问题导致, 我们考虑在Longhorn Server / Vista SP1中取消这一变化.

    不过现在, 您可以在下列措施中任选一项:

    这个 appcmd 指令将为缺省应用程序池关闭 loadUserProfile. 假如您的程序运行于不同的应用程序池(AppPool), 就相应改动一下:

    %windir%\system32\inetsrv\appcmd set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false

    这条命令将把网络服务的临时目录权限改为可读可写。如果你是以另一个身份来运行程序,那么你还需要将那个身份的临时目录权限给打开:
    icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant Users:(CI)(S,WD,AD,X)

    icacls %windir%\serviceprofiles\networkservice\AppData\Local\Temp /grant
    CREATOR OWNER
    :(OI)(CI)(IO)(F)


    脚本错误默认为不在浏览器中显示了


    作为安全策略的一部分,我们关闭了ASP的自动在浏览器中显示脚本错误的提示。也就是说一般用户将不会再看到你的语句到底是哪一行出了差错。取而代之的是这个错误提示:
    --------------------------------------------------------------------------------------------------------------------

    An error occurred on the server when processing the URL. Please contact the system administrator

    --------------------------------------------------------------------------------------------------------------------

    要想恢复到IIS6的状态也很容易,运行下面命令即可:

    %windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:true

    或者你可以在窗口界面中找到以下这个选项:
    <IMG src=
    http://www.cnbeta.com/upimg/070522/hidecloud_135509.jpg
    border=0>

    之后你就能看到这样的错误提示信息了:
    --------------------------------------------------------------------------------------------------------------------

    Microsoft VBScript compilation error '800a03ea'

    Syntax error

    /test.asp, line 4

    Response.Write(
    I love classic ASP
    && foo)
    -------------------------------------^

    --------------------------------------------------------------------------------------------------------------------



    父目录默认是不能访问的


    在IIS6中我们默认屏蔽了父目录的访问,但是一些从XP升级到Vista的用户显然遇到了麻烦。因为在IIS5.1中,父目录默认是可以访问的。所以如果你使用了../../../includeFile.inc这样的路径,你就会得到这样的错误提示:
    --------------------------------------------------------------------------------------------------------------------

    Active Server Pages error 'ASP 0131'

    Disallowed Parent Path

    /test.asp, line 1

    The Include file '../bad.inc' cannot contain '..' to indicate the parent directory.

    --------------------------------------------------------------------------------------------------------------------

    要想恢复到IIS6的状态也很容易,运行下面命令即可:

    %windir%\system32\inetsrv\appcmd set config -section:asp -enableParentPaths:true

  • 信息来源:cnbeta.com
    信息提供:疾风之狼
    责任编辑:疾风之狼
  • 全国服务热线:0371-5501-9681    技术服务QQ:85112407    支持信箱:fuwu@wendalf.com
文章搜索: