Hello, World!
Photo by Markus Spiske: https://www.pexels.com/photo/close-up-photo-of-matrix-background-1089438/

Hello, World!

Have you ever considered learning to develop your own applications from scratch? The task can seem overwhelming at first. To help you along the way, this series of articles will document the process of creating a fully functional application. I'll be embedding my code along the way, so if you get stuck, you'll have something to reference. Let's get started!

Getting started is surprisingly simple. You can get to "Hello World!" in a matter of minutes once you have Visual Studio installed. Simply download the free V.S. Community version of Visual Studio, begin a new project, and follow along. This series of articles will walk you through each step of the process and give you something to reference for your own projects.


Download Visual Studio Community for free

Important: These articles rely on MVC (we will discuss what that means along the way). When you first install Visual Studio, be sure to select ASP.Net and Web Development. I also recommend .Net desktop Development.




Click "Create New Project" once Visual Studio opens. I recommend re-booting your computer if this was your first Visual Studio install. Re-booting can help prevent some confusing errors when you launch your new project.

Select "Create a New Project" under "Get Started"


I recommend matching the name I gave my solution ("DigitalDonutFactory") if you're brand new to this. This can help prevent confusion down the road if you need to copy and paste from my examples. This is by no means a requirement, so feel free to name your Solution as you see fit. If you're wondering why we are making an application for a donut factory.... More on that later. CGI donuts are a thing. This concept will give us plenty of room to introduce creative ideas over time. Whether we need to focus on 3D donuts, sales charts, or 3D donut charts, we'll have the creative runway we need with this concept.

If you plan on giving users the ability to log in, select Individual Accounts for Authentication Type. Leave this at "None" if you aren't interested in accounts, but I do recommend selecting Individual Accounts for most projects. It is simpler to deal with having it and not needing it, as opposed to needing it and not having it, in my opinion.

Change the word "Welcome" to the phrase "Hello LinkedIn World!".

Hit one of the "Play" buttons near the top of you screen in Visual Studio. You'll see I started without Debugging, but either option should work fine. We'll cover debugging as we move forward. For now, just ensure you get your "Hello World" as expected if this is brand new to you. If so, congratulations! You have your first web application built. The articles that follow will begin integrating useful concepts. This initial introduction is simply meant to be a beginner's guide for those that have never worked in Visual Studio or those that are new to MVC. We will get some basic navigation implemented in the next article, then we'll start dropping in some of my favorite libraries. If you follow along, you'll have a strong foundational project/template to work with moving forward.



Controllers/HomeController.cs

using DigitalDonutFactory.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;

namespace DigitalDonutFactory.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
        

Views/Home/Index.cshtml

@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Hello LinkedIn World!</h1>
    <p>Learn about <a >building Web apps with ASP.NET Core</a>.</p>
</div>
        

要查看或添加评论,请登录

社区洞察

其他会员也浏览了