如何为IIS 7中的特定文件夹设置.NET错误页面? [英] How to set .NET Error Pages for a specific folder in IIS 7?
问题描述
自定义错误页面可以应用于IIS中的特定文件夹吗?
Could custom error page be applied to to specific folder in IIS?
例如,我的文件夹名称是 http://my.com/foobar ,在IIS中,我右键单击文件夹名称>>> .Net错误页面图标>>>添加... >> > 404 >>>>>绝对网址>> http://my.com/error.html
For example, my folder name is http://my.com/foobar, in IIS, I right clicked on the folder name >>> .Net Error Pages Icon >>> Add... >>> 404 >>>>> Absolute URL >>http://my.com/error.html
这不起作用。我检查了web.config文件。 IIS也没有修改任何内容。我做错了吗?
This did not work. I checked in web.config file. There is nothing modified by IIS either. Am I doing something wrong?
~~~~~~~~~~~~~~~~
我添加到这个:
~~~~~~~~~~~~~~~~ I add to this:
我尝试了配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors>
<error redirect="error.html" statusCode="403" />
</customErrors>
</system.web>
</configuration>
这不是Go。
所以我试过
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<httpErrors errorMode="Custom" >
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" path="http://my.com/err.html" responseMode="Redirect" />
</httpErrors>
</system.web>
</configuration>
这个有用,但是这个被添加到root下的web.config中,有没有办法添加对于目录web.config?
This worked, but this was added to the web.config under root, is there any way to add for a directory web.config?
推荐答案
我将其添加到目录web.config中,并且它有效。
I added this to directory web.config, and it worked.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" >
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" path="`___REDIRECT URL HERE________`" responseMode="Redirect" />
</httpErrors>
</system.webServer>
</configuration>
我的问题是:这与直接从IIS执行此操作的默认方式有何不同?像这样 -
My question remaining: how is this different from the default way of doing it from IIS directly? Like this -
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors>
<error redirect="error.html" statusCode="403" />
</customErrors>
</system.web>
</configuration>
我听说这在IIS6中工作但不是7 / 7.5?
I heard this is working in IIS6 but not 7/7.5?
这篇关于如何为IIS 7中的特定文件夹设置.NET错误页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!