404 Error page

Last post 04-10-2008 5:35 AM by Benson Yu - MSFT. 6 replies.

Sort Posts:

  • 404 Error page

    04-04-2008, 9:53 AM
    • Loading...
    • maricusa
    • Joined on 04-03-2008, 1:23 PM
    • Posts 15

     

    I created a 404 custom error page for my website, I tested locally and it worked fine but when I tested on the test server and on the live server it's not working fine, for example if I typed a nonexisten page .aspx my page comes fine but if I type a nonexistent page .asp or  php appears the following message in a new window and a download file dialog.

    Internet Explorer cannot download page.asp from www.mysite.com

    Internet Explorer was unable to open this internet site. The requested site is either unavailable or cannot be found. Please try again later

    If I typed a .html page or .ccc or .whatever then appears the html code of my custom page.

    On my local I'm using XP but In the servers I have 2003 SP 1.

    My error page is 404Error.aspx, I just set this up on IIS in my website customs errors and I changed the web config also , this is my web config

    <customErrors mode="On" defaultRedirect="404Errors/404ErrorPage.aspx"/>

     

  • Re: 404 Error page

    04-04-2008, 12:08 PM
    • Loading...
    • docluv
    • Joined on 06-29-2002, 11:16 PM
    • Willow Spring NC
    • Posts 1,317

    You have to map the specific file extensions through the asp.net ISAPI filter. It worked on your workstation because the development web server routes all request through ASP.NET. But in IIS you have to map each specific extension type through the processing filter you want, so you could pass .php to the PHP filter and .aspx through ASP.NET filter. I hope this makes sense to you, there are many examples online on how to map the file extensions in IIS. If you are on a shared hoster or in a shared corporate environmwent where you do not have root access you will have to get them to do this for you (good luck!!).

  • Re: 404 Error page

    04-04-2008, 3:02 PM
    • Loading...
    • maricusa
    • Joined on 04-03-2008, 1:23 PM
    • Posts 15

    Thank you, but I did that and still I'm not getting my 404 custom page for any extension different from .aspx I dont know what else to do.

  • Re: 404 Error page

    04-09-2008, 4:05 AM
    Answer

    maricusa:

    Thank you, but I did that and still I'm not getting my 404 custom page for any extension different from .aspx I dont know what else to do.

     

    Hi maricusa,

    The resouces with .html, .ccc, and .whatever extension by default not handled by ASP.NET, because the requests for these resources will not be routed to ASP.NET ISAPI. However, the “customErrors” feature is provided by ASP.NET runtime. Since ASP.NET don’t handle these requests, the customErrors feature doesn’t work is the expected behavior.

    As docluv said, you should add IIS mapping for these file extensions to ASP.NET ISAPI. I know you did that from your post but I would like to know how you did that exactly. For your reference, I provide the following steps below. Hope they are helpful to you. 

        1. Open IIS manager.
        2. Right click the virtual directory of your web application, and then select “Properties”.
        3. In the “Directory” tab, click the “Configuration…” button.
        4. Click the “Add…” buttion to add mapping. For example, Exectable: C:\WINNT\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll        Extension: .ccc

    However, this method only works for the mapped resources. If you want to provide the 404 error custom page for all the resouces with whatever extension, you should define “Custom Errors” in IIS. For example, please refer to the following steps:

        1. Open IIS manager.
        2. Right click the virtual direcory of your web application, and then select “Properties”.
        3. Click the “Custom Errors” tab.
        4. Double click the “404” item, which default content is “C:\WINDOWS\help\iisHelp\common\404b.htm”.
        5. Change the “Message type” to “URL”.
        6. Set the url of your custom page. For example: /VirtualDirectoryName/PageName.html

     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: 404 Error page

    04-09-2008, 8:57 AM
    Answer

    ASP and PHP extensions are not processed by the ASP.NET DLL, so your ASP.NET redirect in your web.config cannot act on them.  A custom error page defined in IIS is the proper way to handle this, not mapping extensions.  See www.iis.net for help on IIS, same login as here.

    Jeff

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: 404 Error page

    04-09-2008, 11:29 AM
    • Loading...
    • maricusa
    • Joined on 04-03-2008, 1:23 PM
    • Posts 15
    Thank you very much. Finally it worked but now I am seeing something weird. I'm working with aspxerrorpath to capture the page the user is trying to reach. this works fine when is .aspx page, I mean when I type testpage.aspx and that page doesnt exist I get the correct asperrorpath, but when I type testpage.html Im redirected to my custom error page but what I get in asperrorpath is the path of my custom error page. Is this the correct behaviour for a custom error page with pages different that .aspx or there is something obviously wrong?
  • Re: 404 Error page

    04-10-2008, 5:35 AM
    Answer

    maricusa:
    but when I type testpage.html Im redirected to my custom error page but what I get in asperrorpath is the path of my custom error page. Is this the correct behaviour for a custom error page with pages different that .aspx or there is something obviously wrong?
     

    Hi maricusa,

    The “aspxerrorpath” querystirng paremeter is appended by ASP.NET. IIS doesn’t do that job. This is by design.

    If you want the “aspxerrorpath” querystirng paremeter for .htm resource, add .htm extension mapping in IIS. I have already listed the steps in my previous post. Just one thing to append: uncheck the “Check that file exists” option in the “Add/Edit Application Extension Mapping” dialog when add extension mapping.

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (7 items)