如何将异常重定向到 IIS 6 中我无法访问源代码的网站的自定义页面|
我有一个托管在 IIS 5 中的 asp.net 网站,我无权访问源代码,但我可以访问服务器。我需要的是一种服务器级别的方法,当发生“SecurityException”类型的异常时,将用户重定向到自定义错误页面。
由于我无法通过全局 asax 使用它,我想知道是否可以使用 elmah 来捕获错误并将其重定向到特定的 url,而不是记录/邮寄它。
我也对替代方案持开放态度..因此,如果有人知道使用不同方法来做到这一点的技巧,我将非常感激。
谢谢!
此致, 字节从机
I have a asp.net website hosted in IIS 5 and i don't have access to the source code, but i do have access to server. What i need is a server level way to redirect the user to a custom error page when an exception of the type "SecurityException" occurrs.
Since I can't use it via global asax i was wondering if i could use elmah to catch the error and redirect it to a specific url instead of logging/mailing it.
I'm open to alternatives too.. so if someone knows a trick to do this using a different approach I would appreciated very much.
Thanks!
Best regards,
byte_slave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ELMAH 为您记录异常情况。它不会重定向到特定页面。 ELMAH 在您有权访问的 Web.Config 中进行配置。
您还可以在 Web.Config 中设置自定义错误页面。
顺便说一句,我曾经遇到过类似的情况(一台带有源的笔记本电脑被偷了)。我从服务器上取下了二进制文件并对其进行了反编译。您可以尝试使用JustDecompile,反射器,
这是另一个带有更多反编译替代方案的问题: A .net disassembler/decompiler
一旦你有了反编译二进制文件,您可以将项目和解决方案文件放回一起。当然,假设二进制文件没有以某种方式混淆或加密。但这对于网络应用程序来说很少这样做,所以我会尝试一下。
ELMAH logs exceptions for you. It will not redirect to a particular page. ELMAH is configured in Web.Config which you do have access to.
You can also setup a custom error page in Web.Config.
BTW, I had a similar situation once (a laptop with source was stolen). I took the binaries off the server and decompiled them. You can try using JustDecompile, Reflector,
Here is another SO question with some more decompile alternatives: A .net disassembler/decompiler
Once you have decompiled the binaries you can put back together the project and solution files. Of course assuming the binaries are not obfuscated or encrypted in some manner. But this is rarely done for web apps, so I would give it a shot.
好的。所以我解决这个问题的方法是下载并编译 ELMAH 源代码,对代码进行很小的更改以捕获所需的异常,然后重定向到我想要的地址。
Ok. So the way i fix this, was downloading and compiling a ELMAH source code, with a very small change in the code to catch the desired exceptions and then it redirects to the address I want.