Here is very easy step by step process to create a complete(Create Service,Build,Host,Test) simple \ hello world equivalent REST ful service using asp.net core mvc.
Audience: Beginners\Intermediate
Environment :
VS
2015 SP 3
.Net
core sdk (https://www.microsoft.com/net/download/core)
Windows
7
IIS
6.1
Next you will see solution like this
Click on valuecontroller.cs. You will see code like below, this is the default code you will see. We will modify slightly REST services in next screen shot.
Basically controller is the module which receives the
client\web browser http request and processes it. Internally Routing middleware is the responsible for routing call to this valuescontroller and all http requests. Notice attribute routing
[Route("api/[controller]")],
so client have to invoke like www.name.com/../api/values .
Next is [HTTPGet], like HTTP verb, which returns a collection or single entity
Click on Program.cs, you will see code like below. asp.net core has built up from scratch
so it has new fast web server, its built into asp.net core, and its called Kestrel (async web server,
platform independent, written using c libraries). Notice, iisintegration that
is basically reverse proxy. IIS all it does is passes client http request to
kestrel and vice versa.
Now lets build it
Select custom
File system , select the output folder
Open IIS manager, Add
new application, enter alias, select app pool.
Create a new app pool, notice its no manage code (its .net
core)
That’s it.
Goto your favorite browser, type http://localhost/hellorestful/api/values/1
http://localhost/hellorestful/api/values