Your official information source from the .NET Web Development and Tools group at Microsoft.
A few weeks ago at TechEd North America we announced ASP.NET vNext. Today we are releasing the first preview of Visual Studio “14” CTP, which will have support for creating and debugging ASP.NET vNext applications. This post will cover what is ASP.NET vNext and give you a walkthrough of what you can do in this preview.
ASP.NET vNext has been designed to provide you with a lean and composable .NET stack for building modern cloud-based apps. ASP.NET vNext will build on .NET vNext.
.NET vNext is the next major release of .NET Framework. .NET vNext will have a cloud optimized mode which will have a smaller footprint as compared to the full .NET Framework. For more details see this post.
ASP.NET vNext can be best described by highlighting the following scenarios
The following chart shows the feature set that will be available in .NET vNext and .NET vNext (Cloud Optimized)
In this post I’ll outline how you can get the tools and walk you through some of the features which we’ve enabled in this preview.
Getting started is easy. Just download Visual Studio “14” CTP. After that you’ll have everything you need to follow along with the remainder of this post. One important thing to note in this early preview is that you should not install this on your main machine. We recommend installing the product in a VM, a VHD, or a computer that is not used in a production environment because there are known side by side compatibility issues with other versions of Visual Studio. In later previews we will ensure that we have a good side-by-side story, but in this early preview we are not quite there yet.
In Visual Studio you can find the vNext templates under the Visual C#\Web node as shown below.
In the screenshot above, the first template, ASP.NET Web Application, will open up the existing One ASP.NET dialog. The remaining templates are for ASP.NET vNext. Later we will integrate the vNext templates into the One ASP.NET dialog box. There are three flavors of templates here. These templates can run on .NET vNext and cloud optimized .NET vNext.
We have two web templates out of the box; an empty template and a starter template. Let’s take a look at the starter template, ASP.NET vNext Web Application. When you create a vNext Web Application you’ll probably notice that the project files/layout is very familiar. Controller classes go in the Controllers folder, Views are in the Views folder, etc. In addition to some familiar files, we have introduced some new/modified files. I’ll highlight those here.
This class must contain a Configure method that takes an IBuilder parameter, and you configure the HTTP pipeline inside this Configure method.
In Startup.cs you’ll see the Configure method as you have previously. You can add and configure various services that you need in your application. In the snippet above we can see the following customizations.
Now let’s take a look at the project.json file.
Project.json is used by the ASP.NET vNext. This file is where you’ll find items like dependencies (for example NuGet packages or framework references for your project), a list of available build configurations, and a list of commands which can be invoked from the command line.
In the image above you can see that the starter template depends on several NuGet packages. Besides references being in a new file there is another significant change here. In vNext apps the list of dependent NuGet packages in project.json includes only the NuGet packages which are directly referenced by the project. In ASP.NET projects created in previous releases of Visual Studio in packages.config you’ll find the NuGet packages which are directly referenced by your project, and any other NuGet packages which those packages depends on. This new view simplifies things. If you uninstall a NuGet package it will automatically remove it dependencies as well, assuming that no other NuGet package in project.json depends on it.
In the project.json you can see there are two other sections; commands and configurations. Each entry in the commands section corresponds to a command line that may be executed. The configurations element defines the configurations which the project should be built against. Here net45 represents the full .NET desktop CLR and k10 represents the cloud-optimized CLR.
When you create a project in Visual Studio a corresponding .kproj file will be placed in the root of the project. It’s is an MSBuild file like most other project files that Visual Studio creates. Visual Studio uses this file to persist settings which it needs to load/run your application. The ASP.NET vNext runtime does not use this file, it’s only used by Visual Studio. Later this file will also be useful for CI scenarios, like project files are today.
In this preview release you’ll find that all files in your project are listed in the .kproj file. In later versions the files will not be listed in the .kproj. More info on that later in this post. Now that we’ve discussed the artifacts in the project let’s move on to debugging the application, and then add some new content to this project.
In previous versions of ASP.NET, the application and web server configuration were both found in web.config. You can specify your application specific configuration settings in the config file. The file format can be the one of your choice. You can use ini, xml, json and plug in any format that you want. The template uses Microsoft.Framework.ConfigurationModel.Json package to read configuration values from a json file called config.json. Below you’ll find the default contents of config.json from the vNext Web Application template.
Debugging an ASP.NET vNext application is the same as any standard Visual Studio project. Once you start debugging your application you can set breakpoints, use the immediate window, and use all the other features that you are familiar with. Debugging works for both the full .NET desktop CLR as well as the cloud-optimized CLR.
In this new preview we have not enabled the Add View/Add Controller menu options yet. That will be coming later. For now we have created a basic set of item templates that can be used. To get to these item templates you can use the Add New Item menu option.
Let’s add a new controller and view to the starter web template we created. To do that, right click on Controllers and select Add New Item. Once you do that you’ll see the list of available templates.
OK name the controller HelloWorldController and click on the Add button. After that you’ll get a new controller class created with an Index method. In the Index method let’s pass a message to the view that we will create. Just like in previous versions one method to do this is to use the ViewBag property. Let’s add a Message property and set the value to “Hello World”. Your controller class should look like the following.
Now that we’ve created our controller we need to create the corresponding view. The Visual Studio templates have routes configured in the same way as in previous releases. This means we will need to create a new view at /Views/HelloWorld/Index.cshtml. You can use the MVC 5 View Page (Razor) item template to get you started.
After creating the view you can update it to display the message that the controller passes to it. The view item template has the layout and title commented out by default. Since we started with a web application template, which has the layout page in the default location, we can just un-comment that out to enable it. Below is the current contents of the view.
Now that you have created the controller and view, you can visit the page by browsing to /helloworld/index or /helloworld/. Let’s move on to see another way you can add files to your project.
In the previous section we used the Add New Item dialog to add new files to your project. When working with a vNext project, all files/folders in the project folder are automatically included in your project. If you have existing files that you need to add to a vNext project you can simply copy the files into your project folder. Visual Studio will notice the new files and include them. In this preview we have not implemented the ability to exclude files from the project. You can exclude source files from the build process by editing project.json. Now that you’ve seen how to add files to your project let’s move on to see how to add a dependency in your project.
In a vNext app dependencies are declared in the project.json file. In this preview, to add a new dependency you can edit the project.json file. Even though we have not yet enabled the Visual Studio dialogs to simplify adding dependencies, we have implemented another really cool feature that I think you’ll love: dynamic IntelliSense in the project.json file for dependencies. In the screenshot below you can see this in action. The IntelliSense here is showing ClassLibrary1, which is a vNext class library project in my solution.
When adding a reference to a project in the solution the format in project.json for that is “ProjectName”: “”.
In addition to IntelliSense for projects, you’ll also find IntelliSense for NuGet packages. The NuGet package IntelliSense covers package names as well as version, including remote packages. Local packages (those installed with Visual Studio) have the folder icon, and remote packages have the NuGet icon.
When a change to the project.json file is saved, a package restore is started in the background by Visual Studio automatically. The References node in the Solution Explorer is also updated to show this new reference. Below I’ve included a screenshot of that.
Now that we have covered a few basics let’s see how to opt-in to the cloud-optimized CLR.
By default all the vNext projects are configured to use the full .NET vNext Framework. To switch the project to target the cloud-optimized .NET vNext Framework we’ll modify the project properties. In the solution explorer right-click on your web application and select the Properties menu option. A screenshot is below.
In this dialog we can switch the Active Target Framework property .NET Core Framework 4.5 to start using the cloud-optimized .NET. There are a few other properties in this dialog, but for now its a little bit bare bones. Now let’s see how you can deploy your app. In this preview we have enabled publishing vNext apps to Microsoft Azure Web Sites. Let’s take a look at that now.
Publishing to Azure Web Sites is really easy in Visual Studio. For the vNext projects we have a trimmed down version of the Publish Web dialog. In this preview we are supporting publishing to the file system (local folder, network folder, etc.) and publishing to Azure Web Sites. In later versions you’ll see all the existing publish methods enabled for vNext apps. Ok let’s see how you can publish your project to Azure Web Sites.
To publish your vNext app right-click on the project in the Solution Explorer and select the Publish menu option as you would a standard ASP.NET project. After that you’ll see the modified Publish Web dialog.
To publish to Azure Web Sites click on the top button. After signing in you can select an existing site, or create a new one in the following dialog.
For this project let’s create a new Azure Web Site. To do that pick the New button and then configure the name on the Create Site dialog. After creating your site the publish settings are automatically downloaded by Visual Studio. The publish dialog will look something like the following.
At this point you can click on the Publish button to start the publish process. When the publish process starts, the Web Publish Activity window is opened, which will show you the status of the publish operation. Once the publish operation has completed, a browser will be opened with your site’s URL.
In vNext projects we’ve also enabled the selective publishing feature. To use selective publishing, right-click on one or more files in the Solution Explorer and select Publish. You can see publish, preview, and replace menu options in the following screenshot.
That covers the publish support that we have enabled for this release. Let’s move on to discuss command line scenarios.
As you saw above you can use Visual Studio to create, edit and debug your ASP.NET vNext application. You can also use your favorite editor of choice to edit the files and run the application from the command line.
The following image shows an ASP.NET vNext project opened in Sublime. I have changed the About action in the Home Controller
I can run the application by using a command called “k web” from the command line. “web” is a command which is defined in the project.json file.
Once I run the command I can launch the browser and navigate to http://localhost:5000 as specified in my “web” command and see this application running in the browser.
NET vNext will have a cloud optimized mode that enables you to deploy your apps with a copy of the .NET Framework libraries they need. Since the runtime and framework libraries are deployed on an app-basis, each app can run different versions of .NET vNext side-by-side and upgrade separately, all on the same machine. These libraries have been slimmed down significantly to reduce the footprint of the framework, and will be distributed via NuGet.
There were bunch of new improvements to ASP.NET Web Forms in VS2013 Update2 including:
Note: You will be able to use your existing Web Forms apps and run them on ASP.NET vNext which is running on .NET vNext. You will not be able run them on cloud optimized .NET vNext.
You can run your existing application that were built on ASP.NET on .NET vNext. If you want to port your application to run on Cloud optimized .NET vNext, then you will have to see which libraries are supported in Cloud optimized .NET vNext. This is because the cloud optimized .NET vNext has a reduced set of assemblies. You can use the APIPort tool to analyze your app. The tool provides you with two main pieces of data: the platforms that you can easily/reasonably target with your code, and the dependencies that are preventing you from targeting additional platforms.
Please read the following post for more information on how to target multiple platforms.
We will provide with a migration tool which will help you to migrate your existing applications to ASP.NET vNext for both .NET vNext and cloud optimized .NET vNext
If the libraries that you were using were already PCL, then you should be able to use them.
We are actively collaborating with the Mono team so that we can add Mono to our test matrix so we can provide a better experience. We will fix bugs that prevent us from running on Mono.
Since you are running cloud optimized .NET vNext, your app contains the framework and the libraries needed for the app to run. In this case you can self-host your app, host it in IIS and your own environment.
This section will help you find more information about ASP.NET vNext
The ASP.NET site has been updated with all new vNext content and walkthroughs.
Following blogs have content related to ASP.NET vNext which are good to read and follow.
ASP.NET vNext is an open source project released under Apache License Version 2.0. You can follow its progress and find instructions on how to contribute on https://github.com/aspnet
- If you find bugs file issues at GitHub
- Add suggestions for new features on User voice http://aspnet.uservoice.com/forums/252111-asp-net-vnext
- Discuss on the ASP.NET vNext Forums http://forums.asp.net/1255.aspx/1?ASP+NET+vNext
Lastly ASP.NET vNext runs on Mono, on both Mac and Linux. We are collaborating with the Mono team to make sure that our ASP.NET vNext stack just works on Mono.
Following are some articles explaining how to run ASP.NET vNext on Mac and Linux.
- Graeme Christie’s article on running ASP.NET vNext on OSX and Linux
Visual Studio side by side support is not available on this early build. Do not install this CTP on a machine with any other version of Visual Studio installed.
Today’s announcement is just a step towards many more awesome features that will be part of ASP.NET vNext. Please do provide your feedback and thank you for trying out the preview.
What plans do you have about WCF. Can we expect support for WCF or will you provide some alternative for integration scenerios?
Nice work, a long way top go to make it as streamlined as we would expect from Visual Studio.
But.. I'm so sick already of the 'cloud optimized' marketing name. Did Microsoft learn nothing from it's naming missteps in the past? Do we really have to ask Hanselman to do an intervention again?
Hi, I'm trying to install this on a VM that had previous versions of VS. I've uninstalled those, but the new VS14 keeps thinking that there is a previous version installed, and is therefore blocking the new install. What registry key(s) do I have to remove so the new VS14 can proceed (...note: I've spent 20 minutes deleting old VS registry keys to no avail). Thx.
@Mike, In the release notes http://support.microsoft.com/kb/2967191, it mentioned the following: There are known issues when you install Visual Studio "14" CTP 14.0.21730.1 DP on the same computer as Visual Studio 2013. While we expect that an uninstallation of Visual Studio "14" and then a repair of Visual Studio 2013 should fix these issues, our safest recommendation is to install Visual Studio "14" in a VM, a VHD, a fresh computer, or another non-production test-only computer that does not have Visual Studio 2013 on it. All of these Visual Studio side-by-side issues are expected to be fixed soon. There is an installation block in this Visual Studio "14" CTP that will prevent installation on a computer where an earlier version of Visual Studio is already installed. To disable the block that will put the computer in an un-recommended state, add the value "BlockerOverride" to the registry:
I am using openSuse with the latest mono compiled from Github.
The hello world example works fine, but I am getting 'An exception was thrown by the type initialize for HttpApi' for the music and bugs example.
you post: Jumpstart KnockoutJS with ASP.NET MVC/Web Api was one the best of so far for me. I new to knock out.
Please help with the edit function
Thank very much.
Really this post is very informative. Thank you.
I am trying to install this on my Windows 7 machine after removing VS 2013 but I keep getting a Packaged failed error for installing Nuget. Does anyone know how to fix this or where I can get a manual install of Nuget?
@Matthew, is your question about installing VS 14 CTP on that machine? Have you checked "Installing Visual Studio "14" CTP side-by-side with Visual Studio 2013" section in support.microsoft.com/.../2967191 ? We generally recommend a clean machine install for CTP so you don't mess up the old machine... Thanks for the support.
Hi pranav rastogi
Your article is great and gives good information. I also want to share a web link of sagipl with you which contain good information on web design and development, web solutions and much more must visit http://sagipl.com/
@Xinyang Qiu Yes, I get the error when installing to my Windows 7 machine that HAD Visual Studio 2013 installed. I removed all VS 2013 components via Programs and Features. I would presume I am in a good state since the linked KB talks about a built in block to prevent side-by-side installs and I am not hitting that block. Infact VS 14 seems to work fine, I just have no Nuget package manager.
In the FAQ, regarding "Web Forms" you say, "You will not be able run them on cloud optimized .NET vNext". Why? What are the reasons? Also, in the introductory content and walkthroughs, there is no example of web forms. Is "WebForms" heading towards its death? Is MVC the only way forward?
@Abhitalks, Eilon has a really good answer to the webform question you had in this forum post: forums.asp.net/.../1987818.aspx . Feel free to post new discussion topic in forums.asp.net/.../1
@Matthew. This looks like the uninstall of 2013 maybe left some NuGet remains behind and on Dev14CTP install NuGet didn’t install. The solution might be to go to VS extension gallery and install NuGet from there. Since this is still CTP, I'd recommend you to install on a fresh new VM. Thanks!
How can we publish into Windows Server , where is the import profile and publish option in Visual Studio