How to fix badly configured web.config created by a visual studio default project template

0

I'm trying to set up CI and I'm having issue with the generated web.config file after my deployment.

My main question is what do I need to do either to my project in Visual Studio or my server to fix this web.config issue.

Steps I've done.

  1. I've created a ASP.NET Core Web Application project in Visual studio. (It runs when debugging using IIS Express)
  2. I connected it to a repo in Azure DevOps.
  3. Used the default agent pool to build the web artifact
  4. Set up a local agent on the server that will be hosting the site.
  5. Ran the pipeline and passed.
  6. Checked site has been deployed.
  7. Tried running the site and got a 500.19 Error

In visual studio I can use IIS Express to run a localhost of the site and it works.

On my hosted machine it says that the web.config is badly configured.

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module
   IIS Web Core 

Notification
   Unknown 

Handler
   Not yet determined 

Error Code
   0x8007000d 

Config Error

Config File
   \\?\D:\Websites\[My Site Name]\web.config 

Requested URL
   http://[Some IP]:80/ 

Physical Path

Logon Method
   Not yet determined 

Logon User
   Not yet determined 

The generated web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Web Content.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: [A Guid]-->

Using 'https://elmah.io/tools/configvalidator/' it tells me that (8,125) The 'hostingModel' attribute is invalid - The value 'inprocess' is invalid according to its datatype 'String' - The Enumeration constraint failed.

The previous version of the site worked (before connecting my CI to it). It was a simple site with just an Index page, it had the following web.config.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.html" />
                <add value="Default.asp" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

My main question is what do I need to do either to my project in Visual Studio or my server to fix this web.config issue.

Build - YAML

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'ResearchWebsite'
    publishLocation: 'Container'

Deployment - YAML

trigger:
- master

pool: Default

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:



- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: '[Some GUID]'
    definition: '8'
    buildVersionToDownload: 'latest'
    artifactName: 'ResearchWebsite'
    targetPath: '$(System.ArtifactsDirectory)'



- task: IISWebAppDeploymentOnMachineGroup@0
  inputs:
    WebSiteName: '[Site Name]'
    Package: '$(System.ArtifactsDirectory)\**\*.zip'
visual-studio
continuous-integration
web-config
web-deployment
asked on Stack Overflow Jan 20, 2020 by Mandelbrotter

1 Answer

0

I had to install .NET Core 3.1 on my hosting server.

answered on Stack Overflow Jan 20, 2020 by Mandelbrotter • edited Jun 20, 2020 by Community

User contributions licensed under CC BY-SA 3.0