半动态更改 web.config 中的 customErrors
基本思想是我们有一个模仿生产的测试环境,因此 customErrors="RemoteOnly"。我们刚刚构建了一个测试工具,可以在测试环境中运行并检测中断。我们希望它能够撤回详细的错误。但我们不想将 customErrors="On" 打开,因为这样它就不会模仿生产。
我环顾四周,想了很多,我想出的一切都是不可能的。我对这些观点有错误吗?
- 我们无法在运行时打开 customErrors,因为当您调用 configuration.Save() 时 - 它将 web.config 写入磁盘,现在它对于每个请求都是关闭的。
- 我们无法使用它自己的 web.config 将文件符号链接到新的顶级目录,因为我们在 Windows 上,而 Windows 上的 Subversion 不执行符号链接。
- 我们不能使用 URL 映射来创建一个空文件夹 dir2 及其自己的 web.config 并使 dir1 中的文件看起来在 dir2 中 - web.config 不适用
- 我们无法将所有 aspx 文件复制到dir2 及其自己的 web.config 因为没有一个链接是一致的,这是一个可怕的 hacky 解决方案。
- 我们无法根据主机名更改 web.config 中的 customErrors(例如,向测试服务器添加另一个 dns 条目),因为这是不可能/受支持的。
- 我们无法执行任何虚拟目录恶作剧来使其工作。
如果我不是,有没有办法完成我想做的事情?在某些情况下(dns 名称甚至查询字符串值)在站点范围内打开 customErrors?
The basic idea is we have a test enviroment which mimics Production so customErrors="RemoteOnly". We just built a test harness that runs against the Test enviroment and detects breaks. We would like it to be able to pull back the detailed error. But we don't want to turn customErrors="On" because then it doesn't mimic Production.
I've looked around and thought a lot, and everything I've come up with isn't possible. Am I wrong about any of these points?
- We can't turn customErrors on at runtime because when you call configuration.Save() - it writes the web.config to disk and now it's Off for every request.
- We can't symlink the files into a new top level directory with it's own web.config because we're on windows and subversion on windows doesn't do symlinks.
- We can't use URL-Mapping to make an empty folder dir2 with its own web.config and make the files in dir1 appear to be in dir2 - the web.config doesn't apply
- We can't copy all the aspx files into dir2 with it's own web.config because none of the links would be consistent and it's a horrible hacky solution.
- We can't change customErrors in web.config based on hostname (e.g. add another dns entry to the test server) because it's not possible/supported
- We can't do any virtual directory shenanigans to make it work.
If I'm not, is there a way to accomplish what I'm trying to do? Turn on customErrors site-wide under certain circumstances (dns name or even a querystring value)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有 customErrors="On" 或 "remoteOnly" 错误详细信息不会消失,对吗?我的意思是您仍然可以使用自定义错误页面访问它并将其记录到另一个来源。
为什么不在生产环境中的自定义错误页面中记录信息,以便您的工具可以访问它,例如消息队列或应用程序事件日志?当线束遇到故障时,它必须足够智能才能在正确的位置查找完整的错误信息。
无论如何,还有另一件事要考虑。
If you have customErrors="On" or "remoteOnly" the error detail doesnt go away right? I mean you can still access it and log it to another source using your custom error page.
Why dont you just have your custom error page in production log the information somewhere your harness can access it, like a message queue or App event log? When the harness comes across a break it just has to be smart enough to do a lookup in the right place for the full error info.
Another thing to consider anyway.