The goal of this post is to explain the purposes of the most important stuff going on in the process of creating an API for a blog. One considerati...
For further actions, you may consider blocking this person and/or reporting abuse
I just tried this but there was no
ValuesController
generated. There was only aWeatherForecastController
with just aGet
method. There was also nowwwroot
generated. I'm running .Net Core 3.0.100 on Windows 10.I was able to start it and got a result through the browser. Now I can look through the attributes for defining the routes.
Thanks for the post.
Hi Katie! Thanks for your comment, indeed you have differences because I've used netcore 2.2. I'll clarify this in the post. Nevertheless, the explanation of how it works and what the different annotations mean remains the same.
Thanks again!
Hi there Katie, are you using Visual Studio 2019? or are you on VS Code?
I used VS Code. Why, is there a difference?
Not really but I was gonna recommend simply creating the web API project via Visual Studio 2019, since visual studio will template it for you.
Or alternatively using the visual studio 2019 create conroller function, which will create a controller skeleton for you
Odd that the
dotnet new webapi
did not correctly create your project template.perhaps if you were to install
dotnet tool install --global dotnet-aspnet-codegenerator
via powershell, more info on that available here and here
In the future, I'll probably scaffold using VS2019. I only did it through the command line to follow the post.
I think I got different results because I'm using a newer version of .NET Core. There is so much stuff here to learn š
Could be, I can't say I tried the
dotnet new
command yet on .NET Core 3.0.If you'd like I could give it a test at home and let you know my results.
Oh, that's so sweet of you, but it's not really necessary, I've got the gist of what's going on with this. I need to concentrate on building this API for our project. Now at least the structure of how to do it is put together. I'm adjusting things to run async for the rest of the methods.
Well happy developing!
This is too simplistic, I guess anyone can easily obtain same info from "getting started" on the Microsoft website. To be useful, I suggest making the article a bit more challenging, For example, Try to return a specific Http Status code, e.g. 422 to some client library, and actually capture the status code client side.