2013-08-29 21 views
7

我正在創建一個ASP.NET網頁,檢索和插入CRM 2011中的數據。 一切都很好,頁面被部署到服務器和它準備測試。ASP.NET無法擺脫「500 - 內部服務器錯誤」

突然之間出現了一個新的變化,在我刪除了服務器中的文件並重新發布了項目之後(我知道這不是必要的,但仍然是..)我無法再訪問該網站。

我得到的只有500-內部服務器錯誤 您正在查找的資源存在問題,無法顯示。

我試圖在頁頭開啓與調試的調試功能=「真」,我設置

<customErrors mode="Off"/> 
<compilation debug="true" targetFramework="4.5"/> 

在web.config文件,我也嘗試添加

<httpErrors errorMode="Detailed" /> 

但他們都沒有幫助有更好的錯誤信息。

我的web.config文件是:

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <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-ASP-20130619150943;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ASP-20130619150943.mdf"/> 
    </connectionStrings> 
    <!-- 
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367. 

    The following attributes can be set on the <httpRuntime> tag. 
     <system.Web> 
     <httpRuntime targetFramework="4.5" /> 
     </system.Web> 
    --> 
    <system.web> 
    <customErrors mode="Off"/> 
    <compilation debug="true" targetFramework="4.5"/> 
    <httpRuntime/> 
    <pages controlRenderingCompatibilityVersion="4.0"> 
     <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="Forms"> 
     <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/"/> 
    </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> 
    <!-- 
      If you are deploying to a cloud environment that has multiple web server instances, 
      you should change session state mode from "InProc" to "Custom". In addition, 
      change the connection string named "DefaultConnection" to connect to an instance 
      of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. 
     --> 
    <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> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246"/> 
     <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0"/> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246"/> 
     <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0"/> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> 
    </entityFramework> 

    <appSettings> 
    <add key="CRMUserName" value="xxxx" /> 
    <add key="CrmUserPassword" value="yyyy" /> 
    <add key="OrganizationUri" value="https://uuuuuu/XRMServices/2011/Organization.svc" /> 
    <add key="HomeRealmUri" value="" /> 
    </appSettings> 
</configuration> 

我得到一個錯誤信息,當我運行該頁面。 錯誤消息是:
驗證消息的安全性時發生錯誤 System.ServiceModel.FaultException:驗證消息的安全性時發生錯誤。

在錯誤的火災是該區段:

RetrieveAttributeRequest retrieveFreightTerm = new RetrieveAttributeRequest 
    { 
    EntityLogicalName = "account", 
    LogicalName = "address1_freighttermscode", 
    RetrieveAsIfPublished = true 
    }; 

任何想法?

+0

1.你可以截圖,並上傳你經過以上設置後得到的錯誤頁面? 2.我認爲這是IIS7或7.5? – Kev

+1

另請嘗試在您的httpErrors元素中設置'existingResponse =「PassThrough」'屬性。 – Kev

+0

您可以檢查事件查看器,IIS會記錄更多詳細信息。 –

回答

6

我打開從運行IIS服務器的網站,我可以看到詳細的錯誤頁面,所有的信息,我需要

+0

最佳解決方案。謝謝 –

4

很多時候發生在編輯web.config文件後,我們留下了一些標籤沒有正確關閉或者表示格式不正確。這也導致500內部服務器錯誤。

要確保您的web.config至少通過此檢查,請在Internet Explorer中打開它。如果任何標籤被遺漏,IE會顯示相應的錯誤。

+0

這是很好的建議。我的web配置有類似的問題,IE立即發現它。 –