开发者

How can I use an own asp page as 404 error page on a Windows 7 pro IIS 7.5 local installation

开发者 https://www.devze.com 2023-03-15 07:47 出处:网络
I have the following configuration: Running Windows 7 Pro Running local IIS 7.5 ( for web development purposes )

I have the following configuration:

Running Windows 7 Pro

Running local IIS 7.5 ( for web development purposes )

Edited hosts file to be able to use http://www.sitestepper.dev

Site build in subfolder of the inetpub/wwwroot/staplijst

Site can be viewed using http://www.sitestepper.dev/staplijst/whatever-page.htm

I have an http://www.sitestepper.dev/p.asp page I would like to call when an unknown pa开发者_如何学Goge is requested. This technique works fine on the deployed version of this web site (deployed on an Windows 2003 server running IIS 6 - not sure about the 7 but it is the version deployed with Windows 2003 server).

I tried ( in the Edit Custom Error Dialog ) :

  • Execute a URL on this site: with value /staplijst/p.asp

and

  • Respond with a 302 redirect: with value http://www.sitestepper.dev/staplijst/p.asp

I tried this in the properties of the 'Default Web Site' , and I tried this at the staplijst level.

  • Even tried it with values without the /staplijst.

I restarted the default web site after each change. And even stopped/started the Web service.

But nothing seems to work, I keep getting the 'Server Error In Application "DEFAULT WEB SITE"' , HTTP Error 404.0 error.


What am I missing here - probably something obvious, but I don't see it ?


I just configured the following to reproduce your setup:

In the web.config file:

<configuration>
    <system.webServer>
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" 
                   prefixLanguageFilePath="" 
                   path="/p.asp" 
                   responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

In the root of the site I have a simple script called p.asp that does a Response.Write "Hello World".

If I browse to a page that doesn't exist p.asp is redirected to and I see "Hello World".

If I use the following in my web.config:

<httpErrors>
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" 
           prefixLanguageFilePath="" 
           path="http://www.sitestepper.dev/p.asp" 
           responseMode="Redirect" />
</httpErrors>

This redirects as expected to p.asp and again I see "Hello World".

The only thing I can think that is wrong is that you say that p.asp lives in the root of the site: http://www.sitestepper.dev/p.asp but the ExecuteURL and Redirect response mode paths include /staplijst in the path.


To answer my own question: I needed to set the Error response to Custom error pages in the Edit feature settings... of the relevant site for this to work. It was set to 'Detailed errors for local requests and custom error pages for remote requests'.

I never had to do this in previous version of IIS, but maybe in those versions this was implied. Or maybe the host setting www.sitestepper.dev is causing the pages always to behave as local requests - anyway this has changed in IIS 7.5 I'm sure.

I searched for this solution without seeing the answer of 'Kev'. As a rule I tend not to edit config files directly if a solution can be found using the presented user interface panels.

I will accept his response as solution though.

How can I use an own asp page as 404 error page on a Windows 7 pro IIS 7.5 local installation

.

0

精彩评论

暂无评论...
验证码 换一张
取 消