簡體   English   中英

這個 <customErrors> web.config中的錯誤

[英]This <customErrors> error in web.config

我正在嘗試修復。我將項目文件夾上傳到虛擬主機。我的項目在本地運行,但在we.config文件中顯示運行時錯誤。我不知道如何解決此錯誤。我仍然在system.web中添加了該行有問題。 我現在刪除了default.aspx頁面。這是由於缺少默認頁面所致。

Description: An application error occurred on the server. The current custom 
    error settings for this application prevent the details of the application error 
    from being viewed remotely (for security reasons). It could, however, be viewed 
    by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable
     on remote machines, please create a <customErrors> tag within a "web.config" 
    configuration file located in the root directory of the current web application. 
    This <customErrors> tag should then have its "mode" attribute set to "Off".

web.config中

 <?xml version="1.0" encoding="utf-8"?>
  <configuration>
   <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   </configSections>
   <connectionStrings>
  <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-multi_hrms-20150331014837;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-multi_hrms-20150331014837.mdf" />
  </connectionStrings>
   <system.web>
  <customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
  <namespaces>
    <add namespace="System.Web.Optimization" />
  </namespaces>
  <controls>
    <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
  </controls>
</pages>
<authentication mode="None">
  <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<profile defaultProvider="DefaultProfileProvider">
  <providers>
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
  <providers>
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
  </providers>
</sessionState>
 </system.web>
 <entityFramework>
 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v11.0" />
  </parameters>
 </defaultConnectionFactory>
 </entityFramework>
</configuration>

如果沒有名稱作為索引的頁面,則默認在webconfig文件中定義起始頁面,例如

 <system.webServer>
     <defaultDocument enabled="true">
        <files>
          <clear/>
          <add value="Home.aspx" />
        </files>
     </defaultDocument>
</system.webServer>

如果您不處理由於數據庫或任何驗證或頁面中的任何內容引起的任何錯誤原因,則在托管后將顯示此錯誤,就像我們在localhost運行時獲取錯誤頁面一樣,因此要避免它,您可以在Web中定義一個錯誤頁面如下所示的用戶配置文件,並檢查localhost中的錯誤。

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

注意:Home.aspx-用戶的登錄頁面mycustomerrorpage.html-要顯示給用戶的錯誤頁面

嘗試改變

<authentication mode="None">

通過

 <authentication mode="Forms">

您說它現在在發布服務器上? 如果它在IIS 7上,則還必須添加一個元素。

在這里它應該看起來

 <system.web>
<!--<processModel maxIoThreads="100" minIoThreads="20"/>-->
<customErrors mode="Off" defaultRedirect="~/Message/DefaultError">
  <error statusCode="404" redirect="~/Message/Error404"/>
  <error statusCode="500" redirect="~/Message/Error500"/>
</customErrors>

<httpRuntime maxRequestLength="10000"/>
<compilation debug="false" targetFramework="4.5"/>
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="10"  requireSSL="false"  />
</authentication>
</system.web>

IIS 7需要system.webServer節點。 我之前也遇到過同樣的問題。 我也嘗試在IIS配置管理器中進行調整

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM