options1&2 are only going to apply to requests handled by asp.net. You need to change the wildcard script mapping to asp.net. http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/wildcard-script-mapping-and-iis-integrated-pipeline
for #3 you need to use the runAllManagedModulesForAllRequests on the modules section of the web.config. explained at the end of the same module
UPDATE:
This worked for me. I hope it's closer to what you want.
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<handlers>
<remove name="StaticFile"/>
<add name="StaticFile" type="System.Web.StaticFileHandler" path="*" verb="*" resourceType="Unspecified" requireAccess="Read" />
</handlers>
<modules runAllManagedModulesForAllRequests="false"/>
</system.webServer>
</configuration>
Handle error with Global.asax
public class Global : System.Web.HttpApplication
{
protected void Application_Error(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext currentContext = application.Context;
Exception currentException = application.Server.GetLastError();
Debug.WriteLine("Application_Error " + currentContext.Request.PhysicalPath);
application.Server.Transfer("~/CustomErrorTransfer.aspx");
}
}
Or in an HttpModule
public class ErrorHandlerModule : IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.Error += ContextOnError;
}
private static void ContextOnError(object sender, EventArgs eventArgs)
{
HttpApplication application = (HttpApplication)sender;
HttpContext currentContext = application.Context;
Debug.WriteLine("ErrorHandlerModule " + currentContext.Request.PhysicalPath);
Exception currentException = application.Server.GetLastError();
application.Server.ClearError();
application.Server.Transfer("~/CustomErrorTransfer.aspx");
}
}
with this added to the web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<add name="Errors" type="MyRootNamespace.ErrorHandlerModule"/>
</modules>
</system.webServer>
CustomErrorTransfer.aspx used by other pages
<%@ Page Language="C#" %>
<!DOCTYPE html>
<head runat="server"><title></title></head>
<body>
<form id="form1" runat="server">
<div>
<h1>Custom Error Page</h1>
Current Path: <%= Request.CurrentExecutionFilePath %><br/>
Original Path: <%= Request.PhysicalPath %><br/>
</div>
</form>
</body>
</html>