Reputation: 7379
what is the best one to work in .net core? SDK 2.1.301 or Runtime 2.1.1?
I am trying to create a webapi with dotnet, I run dotnet and set http://localhost:5000/api/values/get?Id=1 and fails telling me page not found
I don't know if it is the version of dotnet I installed, I used SDK.
Upvotes: 0
Views: 71
Reputation: 131712
The URL is wrong. It should be http://localhost:5000/api/values/1
. That's specified in the controller method itself with a routing attribute :
The SDK inlcudes the runtime so there's no reason to worry about order of installation.
The SDK contains the tools and libraries needed to create and build a project, like dotnet new
and dotnet build
. It runs on top of the runtime, it doesn't provide its own.
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
This means that the Get
action will be called in response to the GET
verb and the id
parameter will be retrieved from the URL itself.
The runtime contains only the parts that run a program.
UPDATE
The URL just works with the default Web API template. To verify :
dotnet new webapi
to create a new Web API projectdotnet build
to build it and then dotnet run
http://localhost:5000/api/values/1
in any browser. The response will be
value
UPDATE 2
Postman also works, once SSL certificate verification
in Settings > General
is disabled.
The Web API template comes with HTTPS preconfigured and works with a self-signed certificate. Calls to http://localhost:5000
will be redirected to https://localhost:5001
.
Upvotes: 1
Reputation: 1477
In terms of the framework, there is no difference if you use SDK or runtime. The first one is designed for development, while the latter one for production environments.
Issue comes out from your project, routing for e.g., but difficult to say once you need to share more details. Mentioned framework variants are irrelevant here.
Upvotes: 1