0

So I had to change all the links on a certain site, so I put in a PageNotFound page.

I setup web.config to redirect 404 errors to this PageNotFound page.

After going live, the PageNotFound page was the most visited page, something like 5000+.

I later determined that this was the issue: Why is @font-face throwing a 404 error on woff files?

Basically font-face was throwing 4 404 errors on every page.

My question is this, would the PageNotFound page be hit that way? Because I was never redirected to the 404 page, but it was registering as the highest hit page until I fixed the font-face issue.

Community
  • 1
  • 1
Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117

2 Answers2

1

You ask if it would and obviously, "yes," since it happened to you. If you were to attempt to load the resource by typing in the url you would probably receive the redirected 404 response page you set up.

Note that 404 is not "page not found," but rather "resource not found"

404 The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible

horatio
  • 1,426
  • 8
  • 7
  • So does ASP.NET only redirect when an actual Page is not found? Or when you specifically type in the URL or click on a link to the URL – Jack Marchetti Jan 06 '11 at 00:09
  • @Jack - try using Firebug in Firefox and the NET view - you'll see 404s for each resource that fails to load – Ian Mercer Jan 06 '11 at 03:28
  • I used Fiddler and saw the 404's. My question is, does the PageNotFound page get hit then, even though the user isn't redirected. I need to explain to a client why the PageNotFound was hit 5000 times. They think the end user was seeing the PageNotFound page that often. – Jack Marchetti Jan 06 '11 at 04:28
  • to spell it out more clearly: a 404 is sent for each and every resource (not page) that is not available. All you have done is customized the 404 error which is sent. I think you are confusing yourself because the PageNotFound name has the word page in it. If you were to save 404'd image from a page by right clicking it, what is saved will most likely be the 404 page you created.. – horatio Jan 06 '11 at 15:38
1

Like horatio says, for asp.net a page is just another resource! it doesn't matter whether its a page (.aspx), image, css or whatever document. As long its in the asp.net pipeline (which EVERY request is per default on IIS 7) an 404 statuscode would show your page defined under customErrors in web.config

Pauli Østerø
  • 6,878
  • 2
  • 31
  • 48
  • You're not understanding my question. If a 404 is thrown, does the PageNotFound page get a hit even though the user is not redirected to that page? – Jack Marchetti Jan 06 '11 at 04:27
  • of course, why shouldn't it... every image, css, js and what not is a separate request that can throw a 404 error. Of course if the original webpage is found, but some references image is not the user will never see the PageNotFound but no image neither. – Pauli Østerø Jan 06 '11 at 04:30
  • Okay that's what I figured, I just needed to confirm it. Just out of curiosity, if let's say an image isn't found and a 404 is thrown, why isn't the user redirected to a PageNotFound page. Is it only thrown if the actual resource in the URL is not found? Thanks Paul – Jack Marchetti Jan 06 '11 at 04:33
  • why should the user be redirected? this is what we're trying to get you to understand... everything is a resource, a page or a image is no different. a 404 error is only bound to each request for each resource. When you request a page and its found and returned everyone is happy. The browser then parses your html, finds some image and makes a request for that too. A new request for a new resource, which can return a 404 error. No browser cares about that though, fails to show the image and just continues to download the rest of the resources (images, js, css). – Pauli Østerø Jan 06 '11 at 04:39