I think IIS (web.config) settings are overwritten and enforced before actually EPiServer can handle that.
If you really need custom 500 error page for rest of the world and for admins - show detailed view of the error, you could create a bit more complex 500 error page and behind the scene check permissions for the current user - if he/she is able to see detailed messages.
using EPiServer.Security .. if (PrincipalInfo.Current.IsPermitted(Permission.DetailedErrorMessage))
If user is permitted you can use exception manager to render detailed error page:
ServiceLocator.Current.GetInstance<IExceptionManager>().RenderHttpRuntimeError(exception);
Yeah, in the meantime I've found that but it is null.
I found this post:
http://sunali.com/en/2008/01/16/why-does-server-getlasterror-return-null/
I've added globalErrorHandling="Off" in episerver.config but it still gives me null. I am not sure if I should try with Context.AllErrors because the post is from 2008 :)
I tried with it but it is also null. I think that Episerver handles that error and I have to find out how.
Thanks anyway :)
At the end, this is how I done it:
private void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs var exc = Server.GetLastError(); if (exc != null) { if (PrincipalInfo.Current.IsPermitted(SystemPermissions.DetailedErrorMessage)) { ServiceLocator.Current.GetInstance<IExceptionManager>().RenderHttpRuntimeError(exc); } else { var httpException = exc as HttpException ?? new HttpException(500, StringConstants.InternalServerError, exc); Response.Clear(); switch (httpException.GetHttpCode()) { case 403: Response.Redirect("~/403.html", true); break; case 404: Response.Redirect("~/404.html", true); break; default: Response.Redirect("~/500.html", true); break; } Server.ClearError(); } } }
I removed the code from the web config.
I am not sure if it is the best solution but it works for now. If anybody has some better solution, please share :)
Thanks Valdis :)
Hi,
I have a small problem. I want to see the error on the test server, and I am a part of admins in Permissions for Functions so I should see the detailed error, but since we added in the config file custom 500.html for all server errors:
I also see just that page and not the whole error.
If I add
all users get the whole errors. Is there some solution for this?
Thanks in advance :)
Simona