LosManos
LosManos

Reputation: 7692

Runing a REST web site from IIS Express returns 404 Not found

Developing a Dotnet Framework 4.8 REST API in VS2019 and starting IIExpress that way is no problem.
GET http://localhost:51241/api/user returns correct data.

So I start IIExpress from the command line
but then GET http://localhost:8080/api/user returns a 404.
Why?


Command line: & 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /path:C:\DATA\Nav\bin\

GET http://localhost:8080/ returns a 403.14 (not allowed to browse) which is correct.


A clue can be the output:

Copied template config file 'C:\Program Files\IIS Express\AppServer\applicationhost.config' to 'C:\Users\User\AppData\Local\Temp\iisexpress\applicationhost2020130173241776.config'
Updated configuration file 'C:\Users\User\AppData\Local\Temp\iisexpress\applicationhost2020130173241776.config' with given cmd line info.
Starting IIS Express ...
Successfully registered URL "http://localhost:8080/" for site "Development Web Site" application "/"
Registration completed
IIS Express is running.
Enter 'Q' to stop IIS Express

as my site is not called "Development Web Site" but "Nav".
Another clue is that may call results in copies from 'C:\Program Files\IIS Express\AppServer\applicationhost.config' while VS2019 seems to use 'C:\DATA\Nav.vs\Nav\config\applicationhost.config'

The applicationhost.config file IISExpress copies from, is not the same as VS2019 uses as my, failed, run copies from 'C:\Program Files\IIS Express\AppServer\applicationhost.config' but VS2019 seems to use 'C:\DATA\Nav.vs\Nav\config\applicationhost.config'

Upvotes: 1

Views: 4019

Answers (1)

Lex Li
Lex Li

Reputation: 63264

The tricky part to simulate VS launching IIS Express is that you must call IIS Express command line with the correct /config switch pointing to the applicationHost.config file generated by VS (hidden in .vs folder, for VS2015 and above).

Reference

Upvotes: 3

Related Questions