I have a simple API, when I run the API in Visual Studio 2019 it works perfectly, I'm using swagger to see that it worked. Doesn’t matter if its debug or release and I can use ISS Express or Kestrel. While it's called from the IDE it works.
When I use it outside of Visual Studio IDE it does not work. Is a 404 not found. It seems to not read properly the configuration. I tried many things (command line dotnet MyAPI.dll, publishing it and try it in a server…) but if used outside of VS , it does not work. I’m guessing somehow It does not read the properly the configuration because in all tries (outside of IDE) it ends up using default ports (5000 and 5001).
It is probably something simple. The configuration I believe is lost is the one in launcherSettings.json that you can see here:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53907/",
"sslPort": 44369
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyAPI": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:44369;http://localhost:5000"
}
}
}
Any idea what I'm doing wrong?
Edit...
web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
<!-- Config de ultima solucion https://stackoverflow.com/questions/4022434/how-to-set-the-maxallowedcontentlength-to-500mb-while-running-on-iis7-->
<system.web>
<!-- ~ 2GB -->
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- ~ 4GB -->
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
To keep things more simple I'm using now Kestel (simply picking the entry point for the current project). Then what debug does is compile and execute the Debug/*.exe, it runs in 44369 as set in the config.
However if I go to that folder and doble click on the exe it works in port 5001. To this https://localhost:5001/swagger/index.html the response is now a 404 Not Found.