EasyHostingASP.NET | Best and cheap ASP.NET Core RC2 hosting. In this post how we can run and test an ASP.NET Core RC1 application. Yesterday RC2 was made public and it is now time to revisit the subject. This time we are going to create an ASP.NET Core RC2 MVC application, Docker-ize it and analyze how we can run and debug this application.
Once you have installed RC2 please make sure to also install the Visual Studio Extension Docker Tools for Visual Studio 2015 – Preview that provides first class Docker support.
Create an application
Start Visual Studio and create a new ASP.NET Web Core Web Application. Let’s call the solution
HelloRC2 and the project
Web. Select Web Application as template.
So far so good. Let’s try to run this application locally on our developer machine. Select
Web as target and press
F5 to start the application. After compiling Visual Studio will start
Kestrel (the new lightweight Microsoft Web Server) in a console window. It will also open a browser window at
localhost:5000. By default
Kestrel listens at port
If the browser reports an error This site can’t be reached then you might need to hit refresh since
Kestrel was not starting up fast enough and thus was not ready to serve the request from the browser.
Wonderful, we have our ASP.NET Core application up and running. But this is not so exciting because it’s what we have done all the time… Thus let’s come to the more fascinating part, running the application in a Docker container.
Add Docker support
In the Solution Explorer right click on the
Web project and select
Add from the context menu. From the sub-menu select
Docker Support. A folder called
Docker will be added to our project containing a few interesting files. In addition to that the extension also adds two support files to the
Properties folder. These are needed to provide the seamless integration of building, running and debugging Docker containers from within Visual Studio.
Run and debug the application
Make sure you select
Docker as target
F5 to start the application. If you observe the
Output window while the application is building you will notice that the script
DockerTask.ps1 that was added to the
Docker folder is executed. This script will do the following
- build the application
- publish the application
- create a Docker image using the published application
- create and run a container from the above image
- start a browser page listening at
[IP address]corresponds to the IP address of your Docker host. In most cases this is
As a result you should see your Web application running inside a container. The look and feel of the application in the browser is exactly the same as when we were running it directly on our developer machine
While building the container image the script has also added remote debugging support into the image. Thus we should be able to start a debugging session. Let’s do this now. Add a break point to line 18 of the
HomeController. Now in the application select the
About menu and observe how the debugger stops at the break point. We can now observe the content of variables or step through the code line by line – exactly the same way as we’re used when we’re debugging an application running directly on our developer box.
In this post I have demonstrated how we can create an ASP.NET Core RC2 MVC application, deploy the application into a Docker container and remote debug the application running in the container.
Latest posts by Alexia Pamelov (see all)
- Cheap Magento 2.1.6 Hosting Recommendation - June 20, 2017
- Best IIS 10 Hosting Comparison – DiscountService.biz VS WebCity - June 19, 2017
- Find The Best ASP.NET Core 2.0 Hosting Comparison in UK - June 16, 2017