We build an HTTP Module to handle 404 errors on a public SharePoint 2010 project.

We found the new functionality in SharePoint 2010 that sets the FileNotFound property of the Web Application very lacking, so instead we implemented the technique described by Waldek: Better SharePoint 2010 ‘Page not found (404)’ page with the Mavention Page Not Found Widget

Here's the implementation of the HTTP Module:

private string pageNotFoundUrl = "/Pages/page-not-found.aspx";

void HttpApplication_PreSendRequestContent(object sender, EventArgs e)
    HttpResponse httpResponse = httpApplication.Response;
    HttpRequest httpRequest = httpApplication.Request;

    if (httpResponse.StatusCode == 404
        && !httpRequest.Url.AbsolutePath.Equals(pageNotFoundUrl, StringComparison.InvariantCultureIgnoreCase))
        Logger.Warn(String.Format("PageNotFound HttpModule: content at {0} not found.", httpRequest.Url.AbsolutePath));

        if ((!String.IsNullOrEmpty(httpResponse.ContentType))
            && (httpResponse.ContentType.Equals("text/html", StringComparison.InvariantCultureIgnoreCase)))

This works like a charm, except on the Manage Content & Structure section of the site. Obviously, anonymous users won't have access to this, and I can simply remove the HTTP Module from the authoring site where users are signed in, but now I'm curious why I'm seeing the following behavior:

When clicking around the Manage Content & Structure page, I occasionally get an authentication popup. I can cancel the popup and the page would still work OK. After some troubleshooting, I figured out that it was being caused by the PagNotFound HTTP Module.

Here's what I see in Fiddler every time this happens:

Fiddler Trace

So it appears that the page is referencing an image that doesn't exist, browsing to this URL (http://localhost/_layouts/1033/styles/siteTitleBKGD.gif) directly causes the same behavior.

I confirmed that when I turn off the HTTP Module, I get a straight 404 when browsing to this URL. I can also replicate this by making up any invalid URL within http://localhost/_layouts/1033/styles - it doesn't have to be an image.

Any thoughts on this behavior? I'm this close to adding a //HACK to the code to bypass the module for URLs within http://localhost/_layouts/1033/styles.

There's nothing at _layouts/none - I have no idea what that is and why Manage Content & Structure requests it. Browsing to that directly will correctly invoke the PageNotFound HTTP Module.


I have encountered the exact same issue you're having - a HTTP Module that handles 404, and getting 404's (and thus an infinite loop or a 500) when going to Manage Content and Structure.

We also did what you did, and just remove the module for the authoring environment, but another 'short term' workaround until Microsoft sort this, is to put a 1x PNG file with the same filename in the same path that is reporting the error, just to stop it 404'ing.

EDIT: I don't remember /_layouts/none, you might as well just need a //HACK for that. I do believe this is a legitimate bug with SharePoint.

  • These 404 URLs are also called when loading the AssetPortalBrowser and UploadEx dialogs causing similar Access Denied errors and authentication popups. – robwilliams Jul 17 '13 at 23:03

I have solved this problem by checking referrer URL. If not null, it should be equal to request URL. Otherwise it is a resource in the page, I assume. Works like a charm!


I'm seeing the same issue now with siteTitleBKGD.gif, smtTreeViewHeader.gif. Watching the profiler, I see it prompts for credentials for the very first time it requests the file in the folder - you can either sign in or cancel, same result either way. Very annoying.

I have looked at reapplying group policy, thinking it might be a permissions issue, this did not help.

As a workaorund, I found the missing files at the images folder in the hive, and copied them to the 1033/styles folder.

The strange thing was that it was not consistent for all web apps, nor was it even consistent on the same server!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.