If I take a working ASP.NET Core Web App project and copy the code to a new .NET Core Console App project, my web API no longer works.
This is unexpected, since ASP.NET Core is just a library - I do not see why its behavior should be driven by project type.
This is also undesirable, as I want my code to be what affects my app behavior, not some SDK magic.
Steps to reproduce the behavior:
<PackageReference Include="Microsoft.AspNetCore.App" /> whatever that version is (latest).http://localhost:5000/api/ValuesThe same ValuesController.Get() result.
GET http://localhost:5000/api/Values HTTP/1.1
User-Agent: Fiddler
Host: localhost:5000
HTTP/1.1 404 Not Found
Date: Wed, 09 Jan 2019 11:34:19 GMT
Server: Kestrel
Content-Length: 0
Log (level Trace) says:
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:5000/api/Values
dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]
Wildcard detected, all requests with hosts will be allowed.
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]
All hosts are allowed.
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1000]
No candidates found for the request path '/api/Values'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[2]
Request did not match any endpoints
dbug: Microsoft.AspNetCore.Server.Kestrel[9]
Connection id "0HLJM4R6D0RD6" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 12.5322ms 404
Simply alternating between these two lines is enough to break/fix the behavior:
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">
Thank you for your feedback, @sandersaares.
The issue you're facing is by-design. It's required for a project to reference the correct SDK for things to work, when using ASP.NET Core.