Custom 404 Only Works for Extensionless and ASPX URL's
When I visit a page that has no extension (e.g., site.com/some-page), I get the 404 page I set up in the umbracoSettings.config. However, when I visit a page with an extension (e.g., site.com/some-page.html or site.com/some-page.jsdgljl), I get a blank response with a 404 HTTP status code (which appears as a blank page).
Note that I already have this under system.webServer in my web.config:
Maybe that interferes with how Umbraco returns 404 pages in some instances? Before I set existingResponse to PassThrough, I was getting ugly IIS error pages (not the ugly Umbraco 404 pages).
That didn't seem to work. The code to set the content finder is run, but the function TryFindContent never runs (I excluded some of the code for brevity):
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
// This breakpoint is hit.
ContentLastChanceFinderResolver.Current.SetFinder(new PageNotFoundFinder());
base.ApplicationStarting(umbracoApplication, applicationContext);
}
public class PageNotFoundFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
// This breakpoint is never hit.
return contentRequest.PublishedContent != null;
}
}
Same result. Blank page when I visit an HTML URL that doesn't exist (and the correct 404 page when I visit an extensionless URL).
Also, I am seeing the HTML URL in Request.RawUrl in my application_BeginRequest and application_EndRequest functions, so I know at least that IIS is passing on the request to the application. Seems like the problem is with Umbraco somewhere.
Maybe Umbraco sees an extension, assumes the URL is for a static file, and serves up whatever file content it finds... and if it finds no file, it serves up nothing? Seems like others have gotten this to work though, so I'm not sure what would be different about my configuration.
Sorry to dig up an old issue, but this only works for me when using an INotFoundHandler not with a custom IContentFinder. Since the INotFoundHandler is being deprecated in (umbraco 8?) it would be good to get this to work with the IContentFinder also.
Custom 404 Only Works for Extensionless and ASPX URL's
When I visit a page that has no extension (e.g., site.com/some-page), I get the 404 page I set up in the umbracoSettings.config. However, when I visit a page with an extension (e.g., site.com/some-page.html or site.com/some-page.jsdgljl), I get a blank response with a 404 HTTP status code (which appears as a blank page).
Note that I already have this under system.webServer in my web.config:
I am doing some route hijacking and I set up a default controller:
Maybe that interferes with how Umbraco returns 404 pages in some instances? Before I set existingResponse to PassThrough, I was getting ugly IIS error pages (not the ugly Umbraco 404 pages).
I also followed the instructions here to add a wildcard mapping so all requests go to ASP.NET, though that just seemed to break some things on my site, and returned a 500 error instead of a 404 error on pages with extensions: http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/wildcard-script-mapping-and-iis-integrated-pipeline . Here is a shortened version of the handlers section of my web.config that I tried (but that did not work for me):
One final note is that ".aspx" pages (e.g., site.com/some-page.aspx) do return the correct 404 page.
Umbraco 6.1.6. IIS 8.
Hello,
Maybe you could try The new way to do a 404 Umbraco Handler.
Jeroen
Hi Jeroen,
That didn't seem to work. The code to set the content finder is run, but the function TryFindContent never runs (I excluded some of the code for brevity):
Same result. Blank page when I visit an HTML URL that doesn't exist (and the correct 404 page when I visit an extensionless URL).
Hmm that's strange. The code should run. I've had some problems with 404's today myself. Maybe that topic can help: http://our.umbraco.org/forum/developers/extending-umbraco/43866-Alternatives-to-404-in-umbracosettingsconfig?p=4#comment180130
Jeroen
Also, I am seeing the HTML URL in Request.RawUrl in my application_BeginRequest and application_EndRequest functions, so I know at least that IIS is passing on the request to the application. Seems like the problem is with Umbraco somewhere.
Maybe Umbraco sees an extension, assumes the URL is for a static file, and serves up whatever file content it finds... and if it finds no file, it serves up nothing? Seems like others have gotten this to work though, so I'm not sure what would be different about my configuration.
Here is what worked for me in IIS8:
Note that the errorMode="Custom" may not be necessary (I'm not sure).
Sorry to dig up an old issue, but this only works for me when using an INotFoundHandler not with a custom IContentFinder. Since the INotFoundHandler is being deprecated in (umbraco 8?) it would be good to get this to work with the IContentFinder also.
From what I've gathered, using the httpErrors element negates the need for a custom handler.
The only issue I see is that it points to a static path instead of an Umbraco node or something else more dynamic.
is working on a reply...