我正在尝试修复。我将我的项目文件夹上传到web hosting。我的项目在本地运行但在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>
答案 0 :(得分:1)
如果你没有任何名字作为索引的页面,默认然后在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 - 想要向用户显示的错误页面
答案 1 :(得分:0)
尝试改变
<authentication mode="None">
通过
<authentication mode="Forms">
答案 2 :(得分:0)
你说它现在在发布服务器上?如果它在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配置管理器中调整它