Running ASP.NET in IISExpress from command line

5

I am having trouble running my ASP.NET5 from command line under IISExpress.

My current command line setup (thanks to this answer) looks like so

iisexpress.exe /config:"[project_dir].vs\config\applicationhost.config" /site:"WebUI" /apppool:"Clr4IntegratedAppPool"

Note that running the project from within VS2015 works fine.

When I run the command above, IISExpress starts up, it even finds the correct port it should run under. The main problem is every request returns a 502.3.

Looking at the contents of IISExpress\TraceLogFiles I see this error

ModuleName: httpPlatformHandler

Notification: EXECUTE_REQUEST_HANDLER

HttpStatus: 502

HttpReason: Bad Gateway

HttpSubStatus: 3

ErrorCode: The server is currently disabled. (0x8007053d)

What is causing this? Why can't I get this to run!?

asp.net-mvc
asp.net-mvc-5
asp.net-core
iis-express
asked on Stack Overflow Mar 29, 2016 by Chris • edited Jun 20, 2020 by Community

2 Answers

1

As the earlier answer points out, Visual Studio sets %LAUNCHER_PATH% and %LAUNCHER_ARGS% environment variables when launching iisexpress. If you set these, you don't have to run dotnet publish, however the contents of these arguments changes slightly from version to version of Visual Studio. Luckily, you can use Process Explorer to see what's in there. Quoting a good blog post on this:

https://blog.lextudio.com/how-visual-studio-launches-iis-express-to-debug-asp-net-core-apps-d7fd3677e3c3

So in fact Visual Studio silently adds the two environment variables when launching IIS Express, so that ASP.NET Core related bits can be injected.

LAUNCHER_ARGS: -debug -p “C:\Program Files\dotnet\dotnet.exe” -a “exec \”C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2\bin\Debug\netcoreapp1.0\WebApplication2.dll\”” -pidFile “C:\Users\lextm\AppData\Local\Temp\2\tmpFD6D.tmp” -wd “C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2”
LAUNCHER_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe```

When I ran into this issue (I had to use iisexpress instead of just dotnet run since I was running an application with legacy components), I set LAUNCHER_ARGS="-p C:\$XXX\$MY_PROGRAM.exe" and LAUNCHER_PATH: to the above, and launching the application worked for me. I recommend using Process Explorer to find what Visual Studio is putting in there, and using that to craft a launch command.

answered on Stack Overflow Aug 13, 2018 by dmi_
0

The applicationhost.config is likely pointing to your project's root directory, and in that directory, the default web.config file for the project has a line that looks something like the following:

<aspNetCore processPath="%LAUNCHER_PATH%"
            arguments="%LAUNCHER_ARGS%" 
            stdoutLogEnabled="false"
            stdoutLogFile=".\logs\stdout"
            forwardWindowsAuthToken="false"/>

Visual Studio (and the dotnet publish command) will replace the launcher variables during F5-startup with the actual path to the ASP.NET Core application; I'm not sure where this new web.config file is stored through.

That said, I was able to get a command-line invocation of IIS Express working for my ASP.NET Core application with the following steps.

  1. Run dotnet publish.
  2. Copy the applicationhost.config file from the .vs directory to the publish output directory.
  3. Modify the paths in the new applicationhost.config for my application to refer to the publish output directory.
  4. Run iisexpress.exe and point to the new applicationhost.config file.
answered on Stack Overflow Jun 14, 2017 by Steve Guidi

User contributions licensed under CC BY-SA 3.0