Sharepoint 2010 custom 404 page - asp extension - sharepoint

I'm working on a SharePoint 2010 publishing site. It's replacing a legacy site built using asp.
As it's public facing and anonymous, we're implementing a custom 404 page. Strangely, this is not simple OOTB (like usual), but I did manage to deploy a 404 page and link it up using an event receiver. Perfect, works fine.
So, in testing I tried entering some random pages that didn't exist. It worked fine for .htm, .html, and .aspx. Next, I tried the .asp extension, as this is what all outstanding bookmarks / search engine links will be based from. Instead of the 404 page I got a blank page. I checked it out in Firebug, and the file was actually returned with a 404 header, but it has no content. Not good.
Anyone solved this problem? Is a custom http module the only way to go here??
As an aside, another strange behaviour is if you use a unknown extension it will render the html from your 404 page as text! Edit: Also, if you enter an extensionless folder that doesn't exist you get this same behaviour. Wow, this strange beast continues to vex me.
Thanks.
Update
Looks like a HttpModule is the only way to go here. I have this working - if anyone would like complete code let me know. I'd post it here, but the SO code formatter is mangling things.
web.config entry looks like the following:
<add name="PageNotFoundHttpModule" type="ProjectName.PageNotFoundHttpModule, ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fb507da11a891ef3" preCondition="integratedMode" />

SharePoint 2010 ‘Page not found (404)’ page the way it should be

HttpModule sure is the way to go. I followed this page to get it working
http://blog.mastykarz.nl/sharepoint-2010-page-not-found-404/
However, the module only works if I leave out the precondition or else you will run into a blank page.

Related

Fix razor WebPages with friendly URL returning 404 error

I have a website written as razor ASP.Net code wit the extension .cshtml. I wrote the site using WebMatrix and the site runs fine when i run it on web martix's "LocalHost". The links and all my code work, but as soon as I try to run the website from my IIS server the page links no longer work properly. When I click on a link it returns the 404 error page. If I type in the .cshtml extension the page loads correctly and all is right with the world except the file extension. The only page that still works is the index page because it is a default page.
Every place I've checked says that it should run without the extension as a default of asp.net or if it doesn't run as default then use the url re-write plugin.
The Default isn't running and I am unable to use the URL rewrite tool.
What can I do to get the default to work or is there another way to have the extensions not display without using URL re-write
ps. I know that if I put the files in a folder with the link name and rename them to index.cshtml This will work but I feel it is a very backhanded way of doing it so I would prefer not to do it that way.
pps. before any one suggests a solution for mvc I am explicitly NOT USING MVC Logic. thank you.
Try two things:
Set the application pool to ASP.NET 4.0. Then restart I IIS.
Add the following key to <system.webServer> section of Web.Config:
<modules runAllManagedModulesForAllRequests="true" />

How to display an error page for static files when using existingResponse="PassThrough" in IIS 7

To be able to get my application (Umbraco CMS) to handle 404 errors, I need to have following setting in my web.config:
<httpErrors existingResponse="PassThrough" />
It works well for displaying a custom 404 error page from Umbraco, but it doesn't work for displaying a 404 error page when a static file cant be found.
For example http://www.example.com/non-existing-file.png returns a 404 status code, but respons is blank. That fits with this description of the PassThrough mode:
PassThrough – If existingResponse is seen as “PassThrough”, custom
error module will always pass through responses from modules. This
setting will make custom error module return blank response if modules
don’t set any text.
(http://blogs.iis.net/ksingla/archive/2008/02/18/what-to-expect-from-iis7-custom-error-module.aspx)
What is the "custom error module"? And how do I get it to return a non blank response?
Update
After stepping through the request handling routines in Umbraco (with a debugger), I have a better understanding of the problem space. As written in the citation above, when existingResponse="PassThrough" then all handling of http errors is done in the custom modules. So to answer my own question, a "custom error module" is in this instance the "UmbracoModule".
One way to solve this problem would be to create a new custom module that will check for the existence of the static files on the disk. It can be done quite nice, I read the list of static files from IIS and read the configuration of customErrors or httpErrors elements from the web.config to get a custom error page. But I kind of think this is crude solution. I would much rather pass the responsibility back to IIS.
Any ideas?
You're correct. For the benefit of anyone else looking for help with this, here's some extra information on 404 handling.
Old Umbraco wiki page - describes your solution using the file /config/umbracoSettings.config
404 for files - works for Umbraco 7 and describes the use of the tag <httpErrors/>
IIS version 6 fix - fixing on IIS6 and how it compares with IIS7

Can't get IIS 7/Coldfusion to deliver 404

So... we have a custom CMS. We have a rewrite rule that any page request (when a file doesn't exist) goes to the root/index.cfm file. There we search our DB for the page in question. If the page exists, we serve up the correct template,etc. If the page doesn't exist I want to server up a 404 page. Now I "think" I cannot do this in IIS since I need to handle the request in CF, so it has to get through. The file will always exist. When the page doesn't exist I've tried using <cfheader statusCode="404" > and then include some html, it puts The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. at the top of the page before my html. In order to get it to display the page I had to remove the 404 status code handler from IIS.
In addition when I fetch as Google, it get's a 301. However when I view response headers in Firefox I get.
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 16 Jan 2013 21:31:42 GMT
404 Not Found
I've tried a combination of redirecting and all sorts of things. I open to letting IIS handle the 404, if there is a way, but I cannot figure out how to get Coldfusion to correctly deliver a 404 so Google gets it right. Webmaster tools gets mad at me because I am delivering "Soft 404s" before this point, so I am trying to fix that.
I've also tried setting <httpErrors existingResponse="PassThrough" /> whatever the hell that does, but didn't work either. I've been looking up other threads trying to figure this out and just can't.
EDIT: Looking further into this, viewing the header info in both Firebug & Chrome I clearly see the headers say 404. Why would Fetch as Bing and Fetch as Google say differently?
I tested the fact that if I add .cfm to the URLs, it Fetch as Google will deliver see 404. However without the .cfm, it thinks it's 301. Firebug sees both as 404. This seems like a Google issue.
ANSWER Kind of:
So I was doing more testing this morning (Right after I added a bounty actually), and I noticed in webmaster tools, Google correctly noted one of my pages as a 404. So I started looking into it. I have an "Add Trailing Slash Rule". Google notices domain.com/page as a 301 (Correct I guess) to domain.com/page/. But it does notice domain.com/page/ as a 404. I think using the trailing slash rule as I have it is the right way, however, should I be doing something different, or is using the redirect with the slash the "correct" way of doing things, even though Google wants to ding me for it sometimes.
I'm not entirely sure I follow the specifics of your approach, so I will give you a few things that you need to look at in order to get this approach working well (or at least what has worked best for me).
Under "Error Pages", make sure that your 404 error page is set to "Execute a URL on this site" ( I generally set mine to something like "/404.cfm"). This will make sure that your ColdFusion page is called correctly for 404 pages (it sounds like you have this working correctly).
Under "Handler Mappings", double-click on the handler for ".cfm". Then click the "Request Restrictions..." button. It should open to the "mappings" tab. The "Invoke handler only if request is mapped to:" checkbox should NOT be checked.
This can really trip up this sort of operation because it means that IIS won't invoke ColdFusion if the file doesn't exist. This shouldn't be an issue if your 404 is set up correctly, but still something to look into.
While you are in the "Handler Mapping" section, look for the IsapiModule with a path of "*". Mine is always set to ColdFusion - not sure if that makes a difference or not.
The other thing to look at is the "Default Document" setting. Keep in mind that this could impact you when forwarding to a folder.
You might also look at your rewrite rule again and make sure it isn't adding slashes where one already exists.

where can i find the default 404 error page for windows sharepoint service 2.0

Where can i find the default htm file, mapped to show the 404 error in Sharepoint service 2.0. Currently whenever the request for a site hits the 404 error, it goes to the default page, but the point to note here is, which is not the one we set in IIS custom error option.
My requirement here is to make few modification in the 404 error page. I tried mapping the request to a custom error page with <customErros> tag in web.config. But unfortunately, its still showing the default 404 error page. When i checked the viewsource of the error page i can see some comments like, res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
Any idea about this? Thanks in advance
I haven't had to do this but this entry looks quite reasonable: http://blogs.msdn.com/b/jingmeili/archive/2007/04/08/how-to-create-your-own-custom-404-error-page-and-handle-redirect-in-sharepoint-2007-moss.aspx
Basically when you install WSS it hi-jacks IIS. You can still do most of the things you would expect but you need to go through the Central Administration pages and the XML files that control many aspects of SharePoint.

Tracking where a custom 404 is handled - code, IIS, etc?

Is there any means to track where within code a 404 error is handled?
We have a site that we have taken over that doesn't seem to be reacting as expected.
We have changed the IIS custom errors page to point to the new page we would like but something seems to still be redirecting it to the old 404.htm file in the root of this site. We have not been able to track down where or why this happens.
Any suggestions on how we might find the referring logic?

Resources