I have installed ASP.NET Core 2.1 preview 1 from here and the latest preview of Visual Studio.
Then I follow the steps: File > New Project > ASP.NET Core Web Application > Choose API
, check Enable Docker Support (Os: Linux)
and No Authentication
.
This nicely generates project template, as well as a Docker project with docker compose files. This builds fine, and pulls all the required images. However, when I try to run it with Docker, from within Visual Studio, it doesn't seem to work.
In the logs I see the following:
Content root path: /app
Now listening on: http://[::]:80
...
Request starting HTTP/1.1 GET http://localhost:32778/ Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:32778/
Now, when I try to do a GET to http://localhost:32778/api/values (using Postman), no response is seen:
Could not get any response There was an error connecting to http://localhost:32778/api/values.
BUT! The Docker logs show that the request is being made:
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:32778/api/values
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:32778/api/values
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 14.4873ms 307 Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 14.4873ms 307
What am I missing here? If I run the default project with IIS Express, everything works as expected.
EDIT: I've just tested this on ASP.NET Core 2.0, and everything works just fine.
As @andrewbadera pointed out, the repositories changed:
Old : microsoft/aspnetcore-build:2.0
New: microsoft/dotnet:2.1-sdk
Old : microsoft/aspnetcore:2.0
New: microsoft/dotnet:2.1-aspnetcore-runtime
I don't know why the template from visual studio is not using it already, but soon they probably will fix this.
Visual Studio template is generating:
SDK => microsoft/aspnetcore:2.1
ASP NET => microsoft/aspnetcore-build:2.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With