您的位置:首页 > 理论基础 > 计算机网络

IIS7 如何显示、返回详细HTTP500错误信息

2012-02-14 10:16 411 查看
<<<<<<<<<<<<<<本文来自网络,在这里谢谢原创者,给我们提供了这个学习的机会>>>>>>>>>>>>>>>>>>>


通过 IIS 配置按住 WIN + R 打开命令行输入 inetmgr 打开 IIS 管理 左边目录选择目标站点,在右边 IIS 块中双击 错误页 在 错误页 中右边的 操作,选择 编辑功能设置 在 错误响应 中,选择 详细错误,单击 确定 完成配置。



通过命令行
启用详细错误:
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/yourapp" /section:httpErrors /errorMode:Detailed
禁用详细错误:
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/yourapp" /section:httpErrors /errorMode:Custom

通过 web.config 配置
其实,上面在两种配置,最终都会反应到对应的 web.config 中。因此,我们可以直接编辑 web.config。特别是对于买的虚拟主机(Shared Web Hosting),没有权限更改IIS。打开网站目录,找到 web.config 文件(如果没有,就建立一个 txt 文件存为 web.config),找到 system.webServer 配置节,添加配置 <httpErrors
errorMode="DetailedLocalOnly" />。

<configuration>

<system.webServer>

<httpErrors errorMode="DetailedLocalOnly"/>

</system.webServer>

</configuration>
注意

此参数选项可以应用到网站或子目录或虚拟目录。 此参数选项对所有 IIS 应用程序有效,包括 ASP, APS.NET, PHP 等。

如果是 ASP.NET 程序,可能还需要配置 <customErrors
mode=”Off” />

view source print?

1<system.web>
2<customErrors mode=”Off” />
3</system.web>
此外,如果是 ASP 程序,还可以配置 sendErrorsToBrowser 选项:

通过 IIS 配置按住 WIN + R 打开命令行输入 inetmgr 打开 IIS 管理 左边目录选择目标站点,在右边 IIS 块中双击 ASP 在 ASP 页中展开 调试属性 节点 找到 启用客户端调试,选择 true 右边 操作中,单击 应用



通过命令行
启用:
%windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:true
禁用:
%windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:false
注意上面参数中 config 后面不能指定站点目录

其他链接:
The new Configuration System in IIS 7 http://blogs.msdn.com/carlosag/archive/2006/04/25/IIS7ConfigurationSystem.aspx

System.webServer Section Group http://msdn.microsoft.com/en-us/library/ms689429.aspx

Improve PHP Error Messages in IIS 7 http://learn.iis.net/page.aspx/765/improve-php-error-messages-in-iis-7/

Tips for Classic ASP developers on IIS7 http://blogs.iis.net/bills/archive/2007/05/21/tips-for-classic-asp-developers-on-iis7.aspx

IIS 7 父子目录同时安装 WordPress 时固定链接的问题 http://blogs.leoworks.net/php2010/2010/01/13/break-iis7-url-rewrite-rule-inheritance-for-parent-child-wordpress/
\

http://hi.baidu.com/xuwuwx122/blog/item/1de473c9c706f3037f3e6fa0.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: