Join Jess Chadwick for an in-depth discussion in this video Creating a new project, part of Up and Running with ASP.NET 5.
- View Offline
- In the previous video I showed you how to install and configure Visual Studio. In this video, we'll put Visual Studio to work and create our very first ASP.NET 5 application and see it in action. The first thing we'll need is a Visual Studio project to hold all the files we'll be working with. To create one, simply select File, New, Project. Then select the ASP.NET Web Application project type and give your project any name you like. The application I'll be building throughout this course will be a blog.
So, I'm going to name my project AspNetBlog. Next, go ahead and find a place on your computer where you want the project files to be saved. I'll be saving my project in the C Projects folder, but you can feel free to put it anywhere you like on your machine, or just leave it in the default location. At this point, you can leave all the other settings alone and just hit OK to continue. In the last step, we just told Visual Studio that we wanted to create an ASP.NET web application. And now, it's time to let it know what kind of web application we'll be building.
Our options are divided into two categories. On the top, we've still got access to ASP.NET 4.6 Templates. In other words, the previous version of ASP.NET. And on the bottom, we've got what we're here to learn about. The ASP.NET 5 Templates. We've got three ASP.NET 5 Templates to choose from. The Empty template, the Web API template and the Web Site template. Ultimately, they're all just slightly different versions of the same template. The only difference between them is the files that get generated at the beginning.
On the right is the Web Site template. This template is a fully functional ASP.NET 5 application, complete with data access and membership services all preconfigured and ready to go. This is a pretty good template to choose when you're started your own projects, because even if you don't need everything it gives you to start out, you can choose to take advantage of the things you do need and then just delete what you don't use. I won't be showing this template, because by the end of this course we'll end up with an application that has everything this template creates and more.
So, don't worry, you won't be missing anything by not seeing this template in action. Finally, we've got the Empty template. The Empty template is a bare bones template with just the very basic files and recommended layout to get us started with building our application. This template generates very little for us and leaves it up to us to implement everything by hand, which is exactly what I'm looking to do. So, go ahead and choose the Empty template and click OK to continue, and wait while Visual Studio sets everything up.
After a minute or two, Visual Studio will let you know it's done by opening up this welcome page with a bunch of helpful links to help you learn more about the various aspects of developing ASP.NET 5 applications. However, you can just go ahead and close this page as you don't need any of those links. You've got me to guide you through it all. When you close the welcome page, you'll be greeted with the startup class. This is entry point to your ASP.NET 5 application. And currently, the only code that's running on your site. The ASP.NET team has added some default code to the Startup class to demonstate the most basic form of handling a web request.
By responding with "Hello World!" Since this code is already in place, let's just go ahead and execute the application and see it in action. Throughout this course, I'm not going to be clicking the menu options to execute the web site, because I prefer the keyboard shortcuts instead. After a few seconds, Visual Studio is finished compiling and executing the web application using its built-in server called IIS Express. Visual Studio has even automatically opened up a browser so we can see the result. And there it is. The message that we saw earlier.
Hello world! Congratulations. You've built your first ASP.NET 5 web application. Before you close the browser and move on however, try this. Switch back to Visual Studio and change the message in the string to say something else like, "Hello ASP.NET 5!" Then simply save the file, switch back to the browser, and reload to see your change. Notice how we never had to rebuild our entire application. All we had to do was save the C sharp file and ASP.NET did everything else for us automatically.
That's your first taste of one of the nice new development productivity features that ASP.NET 5 introduces in this release. When you're done playing around with this code, go ahead and close the browser, head back into Visual Studio and move onto the next video, where I'll show you how to respond to web requests with more than just hard-coded text.
- Understanding ASP.NET 5's new request processing pipeline
- Downloading client-side libraries using Grunt and Bower in Visual Studio
- Adding ASP.NET MVC 6 to your application
- Handling web requests with controllers
- Rendering dynamic views with Razor markup
- Using Entity Framework to write and read data to a database
- Using TagHelpers to create simple dynamic HTML forms
- Registering and authenticating users with Identity services
- Dynamically update portions on the server using partial rendering
- Using dynamic routing logic to customize URLs
- Exposing data with web APIs
- Leveraging custom configuration and logging
- Increasing application maintainability with dependency injection