2012-07-25 37 views
0

我已經修改我的web.config文件中我的asp.net web應用程序,這樣我顯示自定義錯誤頁:當我運行如何在IIS使用自定義錯誤與ASP.NET

<configuration> 
    <system.web> 
     ...snip 
     <customErrors mode="On" defaultRedirect="WebForms/ErrorPage.aspx"> 
      <error statusCode="404" redirect="WebForms/ErrorPageNotFound.aspx" /> 
     </customErrors>   
    </system.web> 
</configuration> 

網站上的IIS我得到以下錯誤:

Error code: 0x800700b7 
Config section 'system.web/customErrors' already defined. 
Sections must only appear once per config file. 
See the help topic <location> for exceptions 

顯然,我有一些配置層次,在這裏打球,但我不知道我需要看看(我有我的機器上276個web.config文件中),該文件 - 有人能指引我走向正確的方向嗎?

當我找到該文件時,我可以僅刪除頂層customErrors部分,或者這會導致在同一臺機器上沒有定義customErrors的其他Web應用程序出現問題?

回答

1

這部分應該在根web.config進行修改

如果重新接收錯誤,也許你有你的主要應用程序的子目錄幾個web.config文件,你應該開始檢查那些將它們刪除

Clearly I have some config hierarchy at play here but I don't know which file I need to look at (I have 276 web.config files on my machine) - can someone point me in the right direction.

你爲什麼不乾脆用windows搜索找到包含字符串的customErrors

要啓用Windows 7高級搜索文件:

http://answers.microsoft.com/en-us/windows/forum/windows_7-files/in-windows-7-i-want-to-search-for-all-files/aadfe1f1-4a33-406b-8e72-bb920efa4f30

配置文件層次

  1. 全球機。 <windir>\Microsoft.NET\Framework\<ver>\Config\Machine.config
  2. 根網頁配置。 <windir>\Microsoft.NET\Framework\<ver>\Config\Web.config
  3. 網站。 <wwwroot>\Web.config
  4. Web應用程序。 <wwwroot>|IIS Web Site path\<webapp>\Web.config
  5. 文件夾。 <wwwroot>|IIS Web Site path\<webapp>\<dir>\Web.config
+0

我在哪裏可以找到根web.config在c:\ inetpub \ wwwroot中沒有任何東西?我嘗試了高級搜索,但它甚至沒有找到我的應用程序web.config文件(!) – 2012-07-25 09:30:07

+0

我的意思是應用程序的根配置文件。無論如何,我更新了我的答案,向您展示了ASP.Net配置層次結構 – Jupaol 2012-07-25 09:40:06