I have configured the HttpErrors section in my web.config.
My custom error page is shown, but not when an exception occurs outside a web request (eg: Application startup, module initializing...), I get the following error:
The page cannot be displayed because an internal server error has occurred.
How can I make sure that my custom error page is ALWAYS shown?
You can't. The customer error pages are being configured at the start of the ASP.NET application, which fails in your case. There is no ASP.NET pipeline to handle the error pages.
Usually there is not much to do, besides making a proxy that filters out HTTP 500 error messages and replaces it with another message.
Related
Our asp.net web app is returning Error 520 on a page in production though no error in development.
This particular error skips our custom error page and present a different error page with Cloudflare.
As in this image
When you inspect the page, you see
"Error: Promised response from onMessage listener went out of scope"
in console
No error is logged by our logging tools, and we cannot tell why it's skipping our custom error page.
Any direction as to how to solve this?
I am attempting to create a custom error page display to run in my app when there is an issue with the database connection string.
When I alter the string to something invalid, I receive the error mentioned in the title above.
Is there any way to override this page and show a more informative one that would tell me that my DB connection string is wrong?
There is a InvalidOperationException that is thrown in the Startup.cs file, but I'm unsure on how to extract this from the startup file and use it, when my app fails to start in the first place.
Is this possible to do?
You can disable the default error page by using the disableStartUpErrorPage="true" setting in web.config for the IIS hosting module. This will just fallback to another custom error page of your choosing served by IIS, rather than allowing you to show a dynamic custom page.
Documentation
I have a Web.Api project, and I deployed it to Azure Web Sites.
Some times I see many HTTP SERVER ERRORS in dashboard.
Detailed Error Information: Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler System.Web.Http.WebHost.HttpControllerHandler Error
Code 0x800703e3 Requested
URL http://test-server:80/api/Statistics/ShowStories Physical
Path D:\home\site\wwwroot\api\Statistics\ShowStories Logon
Method Anonymous Logon User Anonymous
I don't know how to fix it and why it happens.
UPDATE
I found what this happens because user breaks the internet connections, and my question in next: how to catch this problems, maybe create some custom exception handler, and logger this problems, what this 'http server errors' and not show to Azure dashboard?
See this question: ASP.NET Web API OperationCanceledException when browser cancels the request
I think that if you handle OperationCanceledException correctly, the error will not be logged.
I have an ASP.NET 4 Web Forms app that is using URL Routing. I have the following route specified in Application_Start:
routes.MapPageRoute("Schedule", "Schedule", "~/Schedule.aspx");
Pretty simple. I just want to reroute requests for "http://example.com/Schedule" to "http://example.com/Schedule.aspx". Works great. However, if my application throws an exception while using routing, the Application_Error method in Global.asax is not executed. I see the generic .net error message instead. If I throw the same exception when using the full "Schedule.aspx" it works as expected. Any ideas?
From: http://msdn.microsoft.com/en-us/library/24395wz3.aspx
An error handler that is defined in the Global.asax file will only catch errors that occur during processing of requests by the ASP.NET runtime. For example, it will catch the error if a user requests an .aspx file that does not occur in your application. However, it does not catch the error if a user requests a nonexistent .htm file. For non-ASP.NET errors, you can create a custom handler in Internet Information Services (IIS). The custom handler will also not be called for server-level errors.
I think the bolded text why it is not working as expected. Sorry, but I don't have a nice solution.
If I were to specify a page for redirect using the ASP.NET Custom Errors feature, would my application still spit out the HTTP status code for that particular error?
For example if had a line in my web.config that had all Internal Server Errors redirect to Errors/500.aspx and then I encountered a 500 error, I would then be redirected to my custom Errors/500.aspx page. Will my application still respond with a HTTP 500 at any point in this exchange?
I'm just curious...
No, because your browser would interpret that 500 response as an error and show you it's error. Instead, it probably responds with one of the redirect status codes to send you to the defined error page.