1

我使用 asp.net 4 创建了一个应用程序,它在我的本地服务器上运行良好,但是当我切换到外部服务器时,我的 web.config 出现了一些奇怪的问题,我收到了这个错误

[500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
]

.

似乎该<compilation>部分内部存在一些问题。只是我不得不说,当我删除该<compilation>部分时,我的应用程序可以显示和运行,但无法访问数据库。

网络配置


    <?xml version="1.0" encoding="utf-8"?>
<configuration>

  <configSections></configSections>
  <appSettings />


  <connectionStrings>
    <add name="ImmoEntities" connectionString="metadata=res://*/Model.ImmoModel.csdl|res://*/Model.ImmoModel.ssdl|res://*/Model.ImmoModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=XXXXX;Password=XXXXX;User Id=XXXXX;database=XXXXX&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>


  <system.web>

    <globalization culture="auto:fr-FR" uiCulture="auto:fr-FR" />
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <clear />
        <add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web1.siteMap" />
        <add name="web1" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web1.sitemap" />
        <add name="web" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web.sitemap" />
        <add name="web3" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web3.sitemap" />
        <add name="web4" type="System.Web.XmlSiteMapProvider" siteMapFile="/Web4.sitemap" />
      </providers>
    </siteMap>

    <!-- Web.Config Configuration File -->

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>



    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->





    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->

    <authentication mode="Windows" />
    <httpHandlers>
      <add path="CaptchaImage.axd" verb="GET" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" />
    </httpHandlers>

    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <controls>
        <add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>

        <add tagPrefix="cc1" assembly="MSCaptcha" namespace="MSCaptcha" />

      </controls>
    </pages>

  </system.web>


  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->


  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
  </system.web>




  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

</configuration>

知道可能是什么吗?我尝试了不同的方式,但仍然无法正常工作。

4

1 回答 1

1

确保以下所有具有正确版本的程序集都安装在 GAC 中或位于项目的 Bin 文件夹中。

如果 GAC 中缺少任何未从 bin 引用的程序集,则必须在服务器上再次运行 .net framework 4。

如果 bin 中缺少任何内容,则必须确保在项目中包含该程序集时,将其 Copy to.. 属性标记为 true。或直接将该程序集复制并粘贴到 bin。

System.Design, Version=4.0.0.0
System.Data.Entity, Version=4.0.0.0
System.Web.Extensions, Version=4.0.0.0
System.Web.Extensions.Design, Version=4.0.0.0
System.Windows.Forms, Version=4.0.0.0
System.Web.DynamicData, Version=4.0.0.0
System.Core, Version=4.0.0.0
System.ComponentModel.DataAnnotations, Version=4.0.0.0
System.Data.Linq, Version=4.0.0.0
System.Web.Entity, Version=4.0.0.0
System.Xml.Linq, Version=4.0.0.0

让我知道我是否遗漏了什么

于 2012-04-13T11:07:01.537 回答