将Web应用程序从Windows Server 2008迁移到Windows Sever 2016

时间:2017-03-14 02:44:30

标签: c# iis windows-server-2016

我正在努力为我在学校的一位教授解决问题。他有一个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上的Windows Server,IIS和Web托管,因此我非常感谢有关此错误发生原因的任何信息,或者我可能需要对项目进行哪些更改才能让它在Windows上运行Server 2016。

1 个答案:

答案 0 :(得分:0)

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