http://localhost:56472/test.
throws the ugly yellow ASP.NET error message - The Resource Cannot be Found
.
How do I catch this Request and
- Prevent the ugly yellow
- Strip the period from the Request and redirect?
I do have this in my Global.asax
:
protected void Application_Error(object sender, EventArgs e) {
// Do whatever you want to do with the error
}
But the error is not being caught. Normal 404s are caught here and I redirect to my custom error page successfully.
I'm deploying to Azure PaaS so not much granular control over IIS.
Update: My attempt at rewrite:
<rule name="Strip Periods" stopProcessing="true">
<match url="^(.*[^.])(\.+)$" />
<conditions trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^site.com$" />
</conditions>
<action type="Redirect" url="{MapProtocol:{HTTPS}}://www.site.com/{R:1}" />
</rule>