1
votes

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?

1

1 Answers

1
votes

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.