<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[.NET CORE 3.1 Web API For Beginners. Part -01]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1602927400790-main.png" alt="main.png" class=" img-responsive img-markdown" /><br />
</p><section class="align-center">image from <a href="https://raygun.com/%5B/center%5D" target="_blank" rel="noopener noreferrer nofollow ugc">https://raygun.com/</a></section><p></p>
<p dir="auto">This .Net Core Web API beginners guide is for the software engineering students, self-thought programmers, or anyone who wants to learn the basics of .Net Core Web API.</p>
<p dir="auto">.Net Core is a free and opensource framework to develop applications for Windows, Mac, or Linux and It is the successor of the good old .Net Framework. Nowadays there are lots of programming languages and web frameworks to learn. So should I learn .Net Core? Is it worth it? Okay let’s see,</p>
<ol>
<li>
<p dir="auto">.Net Core is now cross-platform which means if you are using Windows, Linux, or Mac, you can simply develop and run the applications <a href="http://with.Net" target="_blank" rel="noopener noreferrer nofollow ugc">with.Net</a> Core.</p>
</li>
<li>
<p dir="auto">You can develop a wide variety of applications with .Net Core like REST APIs, web applications, mobile backends, IoT applications, etc.</p>
</li>
<li>
<p dir="auto">Fully featured Development IDEs, tools such as visual studio can be used to develop desktop, cloud, and mobile applications. You can even use vs code :)</p>
</li>
<li>
<p dir="auto">We can use C# for development. which is a great OOP language.</p>
</li>
</ol>
<p dir="auto">There are a lot more advanced features than this available with .Net Core. since this article is for beginners I’m not gonna go into that level. So enough intro right? Let’s do some coding.</p>
<p dir="auto">First of all, you need to download and install the .Net Core SDK. Go to <a href="https://dotnet.microsoft.com/download" target="_blank" rel="noopener noreferrer nofollow ugc">this link</a> and download and install the latest .Net Core 3.1 SDK for your operating system.</p>
<p dir="auto"><strong>Note that the next major release of .Net Core is gonna be .NET 5 and they are removing the Core name from the framework to avoid confusion with those using the .Net Framework which is currently on version 4 and .Net Core currently on version 5. Don’t think about this for now. I’ll explain this with a separate article. :)</strong></p>
<p dir="auto"><img src="/assets/uploads/files/1602927553338.net-web.png" alt=".net web.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">We are using dotnet CLI to do all the things.</p>
<p dir="auto">Now open the command line and type “dotnet — version”. If you successfully installed the .Net Core SDK it’ll show the installed version. If you're seeing this we’re good to go :)</p>
<p dir="auto"><img src="/assets/uploads/files/1602927589714-dotnet-v.png" alt="dotnet -v.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">The code editor I’m using is vs code because it’s a cross-platform and an excellent editor. With some extensions installed, We can do lots of things with it. Download from here <a href="https://code.visualstudio.com/" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.visualstudio.com/</a></p>
<p dir="auto">For a better C# development experience install the C#, C# Extensions for vs code, and for our icons look better if you install material icon theme :)</p>
<p dir="auto"><img src="/assets/uploads/files/1602927652274-mt-icon-ext-resized.png" alt="mt icon ext.png" class=" img-responsive img-markdown" /> <img src="/assets/uploads/files/1602927651822-c-ext2-resized.png" alt="c# ext2.png" class=" img-responsive img-markdown" /> <img src="/assets/uploads/files/1602927651354-c-ext-resized.png" alt="C# ext.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Download the Postman client from <a href="https://www.postman.com/" target="_blank" rel="noopener noreferrer nofollow ugc">this link</a> to test the APIs.</p>
<ol>
<li>Open your command line and create a new directory.</li>
</ol>
<pre><code>mkdir hellowebapi
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602927706783-hellowebapi.png" alt="hellowebapi.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Now go to the directory using the cd command like below.</p>
<pre><code>cd hellowebapi
</code></pre>
<ol start="2">
<li>Now let’s create the solution file and template for web API using dotnet CLI.</li>
</ol>
<pre><code>dotnet new sln
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602927781992-new-sln.png" alt="new sln.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">If we don’t give any options sln will take the name of the folder which will be ok for our purpose.</p>
<pre><code>dotnet new webapi -o API
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602927972301-newwebapi.png" alt="newwebapi.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Now we need to add the API project to our solution. let’s go ahead and do that.</p>
<pre><code>dotnet sln add API/
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602928002551-slnadd.png" alt="slnadd.png" class=" img-responsive img-markdown" /></p>
<ol start="3">
<li>Let’s open the project using vs code.</li>
</ol>
<p dir="auto"><img src="/assets/uploads/files/1602928033041-openinvscode-resized.png" alt="openinvscode.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">It’ll take a few seconds to download dependencies. If you are using vs code a pop-up msg will appear to install the required assets. click yes.</p>
<p dir="auto"><img src="/assets/uploads/files/1602928042988-buildrases.png" alt="buildrases.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">After that, we can run the project using dotnet CLI. Open the terminal in vs code using Ctrl + ~ on Windows and Cmd + `on a mac.</p>
<p dir="auto">Cd into the API project and run the project using the below commands.</p>
<pre><code>cd API
dotnet run
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602928081122-dotnetrun-resized.png" alt="dotnetrun.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Now you can see a project is running on <a href="https://localhost:5001" target="_blank" rel="noopener noreferrer nofollow ugc">https://localhost:5001</a></p>
<p dir="auto">Now let’s check the default weather forecast endpoint with the postman.</p>
<p dir="auto">First, we need to disable SSL in the postman. <img src="/assets/uploads/files/1602928113937-postmanssl.png" alt="postmanssl.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Then we can check the default endpoint</p>
<pre><code>https://localhost:5001/WeatherForecast
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1602928137701-postmanendpoint.png" alt="postmanendpoint.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Hola... Now we get the response is back from the server.</p>
<p dir="auto">Wait a minute. I know what you’re thinking. If you’re an absolute beginner you may not have any idea what’s going on. This article is just to get started with the .net core web API. In part 02 I’ll explain what’s all this and what’s happening behind the scenes in detail. Until then feel free to play with this :)</p>
<p dir="auto">Find my original article on medium: - <a href="https://medium.com/@dlbnprabath" target="_blank" rel="noopener noreferrer nofollow ugc">https://medium.com/@dlbnprabath</a></p>
]]></description><link>https://lankadevelopers.lk/topic/714/net-core-3-1-web-api-for-beginners-part-01</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 09:15:41 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/714.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Oct 2020 09:59:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to .NET CORE 3.1 Web API For Beginners. Part -01 on Mon, 02 Nov 2020 04:05:29 GMT]]></title><description><![CDATA[<p dir="auto">Superb article</p>
]]></description><link>https://lankadevelopers.lk/post/3998</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3998</guid><dc:creator><![CDATA[Dinuja Senpura]]></dc:creator><pubDate>Mon, 02 Nov 2020 04:05:29 GMT</pubDate></item><item><title><![CDATA[Reply to .NET CORE 3.1 Web API For Beginners. Part -01 on Sun, 18 Oct 2020 15:28:07 GMT]]></title><description><![CDATA[<p dir="auto">Thanks man , great article</p>
]]></description><link>https://lankadevelopers.lk/post/3971</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3971</guid><dc:creator><![CDATA[root]]></dc:creator><pubDate>Sun, 18 Oct 2020 15:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to .NET CORE 3.1 Web API For Beginners. Part -01 on Sun, 18 Oct 2020 07:00:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/122">@BuddhikaNelum</a> great , Thank you very much</p>
]]></description><link>https://lankadevelopers.lk/post/3968</link><guid isPermaLink="true">https://lankadevelopers.lk/post/3968</guid><dc:creator><![CDATA[Nubelle]]></dc:creator><pubDate>Sun, 18 Oct 2020 07:00:38 GMT</pubDate></item></channel></rss>