【问题标题】:Migrating Web Application from Windows Server 2008 to Windows Sever 2016将 Web 应用程序从 Windows Server 2008 迁移到 Windows Server 2016
【发布时间】:2017-03-14 02:44:30
【问题描述】:

我正在为我在学校的一位教授解决一个问题。他有一个 C# Web 项目,他正试图将其从运行 Windows Server 2008 的计算机转移到运行 Windows Server 2016 的较新计算机上。它由 IIS 提供服务,学生通过导航到计算机的 IP 地址来访问应用程序。电脑。

在旧计算机上,他只需将项目文件夹复制到 C:\inetpub\wwwroot 中,当他从另一台计算机导航到 localhost 或他的 IP 地址时,应用程序就会运行。但是,当他将项目文件夹复制到 C:\inetpub\wwwroot 时,项目不会运行。反而, this is the screen he gets。如果您单击“autograder”文件夹(这是他尝试托管的项目文件夹),this HTTP error occurs。 web.config 文件位于此处 - C:\inetpub\wwwroot\autograder\Bin\WebApplication1\WebApplication1\web.config

在网上四处寻找解决方案后,我确保 wwwroot 文件夹具有所需的权限(Web.Config - Cannot read configuration file due to insufficient permissions),但我不确定为什么错误说它无法读取配置文件,也不知道 Windows 有什么不同Server 2016 阻止该项目像在 Windows Server 2008 上那样运行。

这是 web.config 文件:

    <?xml version="1.0" encoding="utf-8"?>
<!--
  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 -->
    <!-- add System.Data.Entity.Infrastructure.SqlConnectionFactory -->
    <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-WebApplication1-20140618141327;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebApplication1-20140618141327.mdf" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0" />
    <httpRuntime targetFramework="4.0" />
    <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="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="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
    <system.webServer>
        <rewrite>
            <rewriteMaps>
                <rewriteMap name="start">
                </rewriteMap>
            </rewriteMaps>
        </rewrite>
        <defaultDocument>
            <files>
                <add value="Student.aspx" />
                <add value="student" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

我通常是 Windows Server、IIS 和 Windows 上的网络托管的新手,因此我非常感谢有关为什么会发生此错误或我可能需要对项目进行哪些更改才能使其在 Windows 上运行的任何信息服务器 2016。

【问题讨论】:

  • 您的应用程序池在哪个用户下运行?
  • 自动分级机(UOFMICHGANDEARB\boss)。 'boss' 是这台计算机的管理员帐户。

标签: c# iis windows-server-2016


【解决方案1】:

事实证明,web.config 文件本身就是问题所在。我重置了 web.config 文件的内容,并且能够导航到应用程序的主页。将 web.config 文件拼回后,我发现了一组它不喜欢的标签,这就是它无法正确读取配置文件的原因。

【讨论】:

    猜你喜欢
    • 2011-05-11
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 2021-05-22
    • 1970-01-01
    相关资源
    最近更新 更多