简体   繁体   English

这个 <customErrors> web.config中的错误

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

I'm trying to fix .I uploaded my project folder to web hosting.My project run in local but shows run time error in we.config file.I dont know how to fix this error.I added the line in system.web still having problem. 我正在尝试修复。我将项目文件夹上传到虚拟主机。我的项目在本地运行,但在we.config文件中显示运行时错误。我不知道如何解决此错误。我仍然在system.web中添加了该行有问题。 I deleted the default.aspx page now.IS this problem is due absence of default page. 我现在删除了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 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>

if you don't have any page with name as index,default then define the starting page in webconfig file like 如果没有名称作为索引的页面,则默认在webconfig文件中定义起始页面,例如

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

if you don't handle any error cause due to database or any validation or anything in your page then after hosting it will show this error like we get the error page at localhost runtime , so to avoid it you can define one error page in web config file like below for user and check error in localhost. 如果您不处理由于数据库或任何验证或页面中的任何内容引起的任何错误原因,则在托管后将显示此错误,就像我们在localhost运行时获取错误页面一样,因此要避免它,您可以在Web中定义一个错误页面如下所示的用户配置文件,并检查localhost中的错误。

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

note: Home.aspx -- the landing page for the user mycustomerrorpage.html -- the error page the want to show to the user 注意:Home.aspx-用户的登录页面mycustomerrorpage.html-要显示给用户的错误页面

try to change 尝试改变

<authentication mode="None">

via 通过

 <authentication mode="Forms">

you said it is on a publication server now?? 您说它现在在发布服务器上? if it is on IIS 7 you must also add a element. 如果它在IIS 7上,则还必须添加一个元素。

here what it should look 在这里它应该看起来

 <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 requires the system.webServer node. IIS 7需要system.webServer节点。 I run tru same problem before. 我之前也遇到过同样的问题。 I also tried tweaking it in IIS configuration manager 我也尝试在IIS配置管理器中进行调整

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM