2010-12-06 74 views
21

我創建了一個asp.net網頁並將其上載到網絡服務器上。但是,當我嘗試遠程查看頁面時,我收到有關web.config文件中的customerror標記的錯誤。該頁面在本地工作,沒有錯誤或警告。同樣,如果我將該頁面上傳爲.html文件,我可以遠程查看它。 我看到很多其他人有這個錯誤,但'解決方案'只是說要將customErrors標記更改爲'關',我已經完成並且不工作,你知道是否存在Web服務器的問題或這裏可能是什麼問題?Asp.net - <customErrors mode =「Off」/>嘗試訪問工作網頁時出錯

以下是錯誤頁面:在 '/' 應用

服務器錯誤。運行時錯誤 說明:服務器上發生應用程序錯誤。此應用程序的當前自定義錯誤>設置可防止應用程序錯誤的詳細信息被遠程查看(出於安全原因)。但是,它可以通過在本地服務器上運行的瀏覽器來查看。

詳細信息:要使此特定錯誤消息的詳細信息在遠程機器上可見,請在位於當前Web應用程序根目錄下的「web.config」配置文件中創建一個標記。這個標籤>然後應該將其「模式」屬性設置爲「關」。

<configuration> 
    <system.web> 
     <customErrors mode="Off"/> 
    </system.web> 
</configuration> 

注意:您看到可以用自定義錯誤頁替換的當前錯誤頁由>修改應用程序的>配置標記的「defaultRedirect」屬性,使之指向自定義錯誤頁面URL。

<configuration> 
    <system.web> 
     <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> 
    </system.web> 
</configuration> 

這裏是我的web.config文件:

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <customErrors mode="Off"/> 
    </system.web> 

    <system.web> 
    <compilation debug="true"/> 
    <authentication mode="None"/> 
    </system.web> 
</configuration> 
+0

@jvanrhyn可能發現你的問題。如果沒有,檢查:http://stackoverflow.com/questions/2830361/custom-error-mode-in-web-config-file – PHeiberg 2010-12-06 07:15:43

+0

我得到了頁面遠程工作,有2個web.config文件,我改變了「帳戶」文件夾中有一個錯誤。我本來應該改變項目根目錄中的那個,但是很愚蠢地沒有看到它。 jvanrhyn也是對一個標籤,謝謝。 – bobby123 2010-12-06 17:29:51

回答

39

您應該只有在你的配置文件中的一個<system.web>

<system.web> 
    <customErrors mode="Off"/> 
    <compilation debug="true"/> 
    <authentication mode="None"/> 
    </system.web> 
</configuration> 
+8

另外值得注意的是,「關」區分大小寫,正如我剛剛在嘗試解決相同問題20分鐘後發現的那樣 – 2013-09-12 03:29:46

-1

在將來某個時候 註釋掉web.config中的下列代碼

<!--<system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
    </system.codedom>--> 

更新下面的代碼。

<system.web> 
    <authentication mode="None" /> 
    <compilation debug="true" targetFramework="4.6.1" /> 
    <httpRuntime targetFramework="4.6.1" /> 
    <customErrors mode="Off"/> 
    <trust level="Full"/> 
    </system.web> 
相關問題