404 for .html files

D

Diane Wilson

I just found out that ASP.NET (1.1) does not have
generalized support for "page not found" errors.
The web.config setup for 404 errors only functions for
missing .aspx pages.

How do I configure IIS to provide 404 handling support
for a complete web site with a mixture of .aspx and
..html pages?

Thanks,
diane
 
K

KMA

Strangely enough I hit this last night. I have the added disadvantage that I
can't configure IIS directly cos I use a host that doesn't allow it. They
*do* allow replacing their standard 404 with something else though. Could
you write a new html "official" 404.html page that redirects to My404.aspx.
Just a though; I look forward to see the real way to handle this.
 
H

Hans Kesting

Diane said:
I just found out that ASP.NET (1.1) does not have
generalized support for "page not found" errors.
The web.config setup for 404 errors only functions for
missing .aspx pages.

How do I configure IIS to provide 404 handling support
for a complete web site with a mixture of .aspx and
.html pages?

Thanks,
diane

See the "Custom Errors" tab in the properties of the site.

Hans Kesting
 
D

Diane Wilson

See the "Custom Errors" tab in the properties of the site.

OK, thanks! that helps locally, but not on my hosting site.
(which gives me limited options for 404.html or 404.asp
but not 404.aspx -- sigh)
Diane
 
D

Diane Wilson

404.asp:

<% Response.Redirect("404.aspx") %>


-- OR --

404.html

<script>
location.replace("404.aspx");
</script>
Thanks! I like the .asp solution better; for things that *have*
to work, I never want to trust client-side scripts.

Diane
 
C

Colin Peters

This helps get round the ugly bog standard message. But is there a way
to find out what the non existant page name was. I want to implement my
own 404 that looks at the non-existant page and tries to offer an
alternative. I figure most 404s come from mis-spillangs.
 
D

Diane Wilson

This helps get round the ugly bog standard message. But is there a way
to find out what the non existant page name was. I want to implement my
own 404 that looks at the non-existant page and tries to offer an
alternative. I figure most 404s come from mis-spillangs.

For .aspx, the HttpRequest object (Page.Request) has URL string
that was requested.

However, if you use one of the above redirect techniques, you'll only
have the page that issued the redirect. So it's necessary to have
executable logic on the first error page in the chain. If your
host lets you code a 404.asp for all 404 errors, that's where you'd
have to put the code.

If your site has its own search capability, I'd certainly put the
search field and button on whatever 404 handling page you use.

Diane
 
C

Colin Peters

Diane said:
For .aspx, the HttpRequest object (Page.Request) has URL string
that was requested.

However, if you use one of the above redirect techniques, you'll only
have the page that issued the redirect. So it's necessary to have
executable logic on the first error page in the chain. If your
host lets you code a 404.asp for all 404 errors, that's where you'd
have to put the code.

If your site has its own search capability, I'd certainly put the
search field and button on whatever 404 handling page you use.

Diane

I've already got the aspx misspellings catered for. I just wondered if
there was a way to catch someone accessing the site via "abc.xyz", or
just "abc".

Unfortunately I can only replace my hosts 404b.html, so I'm a bit stuck
there. I'll certainly add a search field to my NotFound.aspx.

Still, I'm quite happy. At least the visitor never gets the standard 404
message, which was anyway in German!

Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top