Getting Started with ASP.NET 5 for OS X, Linux, and Windows (2015)
4 Deploying ASP.NET 5 on Windows
In this chapter we will learn how to deploy ASP.NET 5 on Windows.
4.1 Getting Started
In this section we start to deploy ASP.NET 5 on Windows. In this book I use ASP.NET 5 preview, beta4. For illustration, I use Windows 8.1. Please follow installation steps on next section.
4.2 Deploying ASP.NET 5
This installation process is based on this documentation, https://github.com/aspnet/Home/blob/dev/GettingStartedDeb.md . In this section, we install ASP.NET 5 on Windows. Firstly, you update your Windows.
In general, to install ASP.NET 5 on Ubuntu, you can do the following steps:
· Installing .NET
· Installing DNVM
· Installing git (optional)
4.2.1 Installing .NET
You need the latest version of .NET Framework runtime. To install it, you can download it on https://www.microsoft.com/net .
4.2.2 Installing DNVM
You can install DNVM via Command Prompt. Open CMD and type this command.
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
If success, you can verify where dnvm is by typing this command.
where dnvm
If got error, check your PATH configuration. Make sure .dnx path already added.
The next step is to upgrade DNVM. Type this command.
$ dnvm upgrade
Now you already installed dnvm. It will be used to manage ASP.NET 5 runtime on Windows. You can verify dnvm by typing this command.
$ dnvm help
So you see a list of dnvm parameter.
You can also see a list of your DNX runtime by typing this command.
$ dnvm list
4.2.3 Installing git
This task is optional but I recommend to install it because we want to run the sample app from https://github.com/aspnet/Home . You can install git by downloading it on https://git-scm.com/downloads .
4.3 Testing
To test our ASP.NET 5, we use code samples from https://github.com/aspnet/Home . We clone this code samples and then restore all required libraries using dnu command.
Type these commands.
$ git clone https://github.com/aspnet/Home
$ cd Home
$ dnu restore
Now you are ready to run code samples.
4.3.1 ASP.NET Console
To run ASP.NET Console, we can use dnx. Firstly, navigate to ConsoleApp project.
Type these commands.
$ cd samples/latest/ConsoleApp/
$ dnx . run .
If success, you can see a message "Hello World" on Terminal.
4.3.2 ASP.NET 5
To run ASP.NET 5 app, we can use dnx with kestrel. Firstly, navigate to HelloWeb project.
Type these commands.
$ cd samples/latest/HelloWeb/
$ dnx . kestrel
When you run these commands, you may get a security confirmation. Please click Allow access button to give a security permission.
Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET 5 app.
To stop kestrel, you can type exit.
exit
4.3.3 ASP.NET MVC
To run ASP.NET MVC, we can use dnx. Firstly, navigate to HelloMvc project.
Type these commands.
$ cd samples/latest/HelloMvc/
$ dnx . kestrel
Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET MVC app.
To stop kestrel, you can type exit.
4.4 Development Tools
The next step is to build program. To write a program, you can use any text editor. Microsoft also provides Visual Studio Code. It runs on Windows, Linux and Mac. You can download it on https://code.visualstudio.com/ .