John Källén
John Källén

Reputation: 7963

Can I use IIS Express using .NET Framework 4.8 using a .csproj file written in the SDK format?

Due to external factors, my project cannot be moved to .NET 6 or later; I'm stuck on .NET Framework 4.8 for the foreseeable future. I have a project that consists of various WebApi controllers. I've written the .csproj for it, and added it to my SLN file. Here is what it looks like right now:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <ProjectGuid>{F07D38E4-5178-4317-84A5-D22ED9A4030A}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MyProject.Controllers</RootNamespace>
    <AssemblyName>MyProject.Controllers</AssemblyName>
    <TargetFramework>net4.8</TargetFramework>
    <LangVersion>9.0</LangVersion>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <RunCommand>$(MSBuildExtensionsPath64)\..\IIS Express\iisexpress</RunCommand>
    <UseIISExpress>true</UseIISExpress>
    <Use64BitIISExpress />
  </PropertyGroup>
   ....

The project compiles fine, but after configuring Launch settings to use IIS Express I get the following error:

Unable to start process C:\Program Files\MSBuild\..\IIS Express\iisexpress.exe. 
The web server request failed with status code 500, Internal Server
Error. The full response has been written to
C:\Users\jkl\AppData\Local\Temp\DebuggingHttpFailures\HttpFailure_01-08-33.html

The file referred to in the error message contains the text:

DEBUG request is not valid.

I've found some blogs and web sites that recommend stopping Visual Studio, deleting the .vs folder, and reopening the solution, but this has met with no success. Removing the <RunCommand> element causes another error, so it seems I'm required to include it in the .csproj file.

What could be causing this error? What could I be doing wrong?

Upvotes: 1

Views: 577

Answers (1)

Roy
Roy

Reputation: 1

My .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <OutputType>Library</OutputType>
    <UseWindowsForms>true</UseWindowsForms>
    <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
    <RunCommand>$(MSBuildExtensionsPath64)\..\IIS Express\iisexpress</RunCommand>
    <RunArguments>/config:./iisexpress.config</RunArguments>
  </PropertyGroup>
  ...

Note: The file iisexpress.config is a copy of .vs/xxx/config/applicationhost.config because I prefer to view and edit it as any other source file.

Upvotes: 0

Related Questions