The ASP.NET team is proud to announce general availability of ASP.NET Core 2.0. This release features compatibility with .NET Core 2.0, tooling support in Visual Studio 2017 version 15.3, and the new Razor Pages user-interface design paradigm. For a full list of updates, you can read the release notes and you can check the list of changed items in the ASP.NET Announcements GitHub repository for a list of changes from previous versions of ASP.NET Core. The latest SDK and tools can be downloaded from https://dot.net/core. Read the .NET Core 2.0 release announcement for more information and watch the launch video:
With the ASP.NET Core 2.0 release we’ve added many new features to make building and monitoring web apps easier and we’ve worked hard to improve performance even more. More details about these features are available in our follow up post about ASP.NET Core features.
Updating a Project to ASP.NET Core 2.0
ASP.NET Core 2.0 runs on both .NET Framework 4.6.1 and .NET Core 2.0, so you will need to update your target framework in your project to netcoreapp2.0 if you were previously targeting a 1.x version of .NET Core.

Figure 1 – Setting Target Framework in Visual Studio 2017
Next, we recommend you reference the new Microsoft.AspNetCore.All metapackage instead of the collection of individual Microsoft.AspNetCore.* packages that you previously used. This new metapackage contains references to all of the AspNetCore packages and maintains a complete line-up of compatible packages. You can still include explicit references to specific Microsoft.AspNetCore.* package versions if you need one that is outside of the lineup, but our goal is to make this as simple a reference as possible.
What happens at publication time? We know that you don’t want to publish the entire AspNetCore framework to your target environments, so the publish task now distributes only those libraries that you reference in your code. This tree-pruning step should help make your publish process much smoother and easier to distribute your web applications.
More information about the features and changes you will need to address when migrating from ASP.NET Core 1.x to 2.0 can be found in our documentation.
Introducing Razor Pages
With this release of ASP.NET Core, we are introducing a new coding paradigm that makes writing page-focused scenarios easier and simpler than our current Model-View-Controller architecture. Razor Pages are a page-first structure that allow you to focus on the user-interface and simplify the server-side experience by writing PageModel objects.
If you are familiar with how to configure your ASP.NET Core Startup class for MVC, then you already have the following lines in your Startup class:
Surprise! The AddMvc and UseMvc configuration calls in your Startup class also activate the Razor Pages feature. You can start writing a Razor Page by placing a new cshtml file called Now.cshtml in the Pages/ top-level folder of your application. Let’s look at a simple page that shows the current time:
This looks like a standard MVC View written in Razor, but also has the @page directive at the top to indicate that this is a stand-alone Razor Page built with that paradigm. HtmlHelpers, TagHelpers, and other .NET Code is available to us in the course of the page. We can add methods just as we could in Razor views, by adding a block level element called @functions and writing methods into that element:
We can build more complex structures by taking advantage of the new PageModel object. The PageModel is an MVVM architectural concept that allows you to execute methods and bind properties to the Page content that is being rendered. We can enhance our sample by creating a NowModel.cshtml.cs C# class file in the Pages folder with this content:
With this class that inherits from PageModel, we can now do more complex interactions and build out a class that can be unit tested. In this case, we are simply loading the LastModified property on the Now page and setting that to the LastModified property. Also note the OnGet method to indicate that this PageModel handles the HTTP GET verb. We can update our Razor Page with the following syntax to start using the PageModel and output the last update date:
For more information, check out the ASP.NET Core documentation on getting started with Razor Pages.
Updated Templates and SPA Templates
The templates that ship with ASP.NET Core have been enhanced to not only include a web application that is built with the MVC pattern, but also a razor pages web application template, and a series of templates that enable you to build single-page-applications (SPA) for the browser. These SPA templates use the JavaScript Services functionality to embed NodeJS within ASP.NET Core on the server, and compile the JavaScript applications server-side as part of the .NET build process.
These same templates are also available out of the box at the command-line when you type dotnet new:

Figure 3 – Templates available with the dotnet new command
DbContext Pooling with Entity Framework Core 2.0
Many ASP.NET Core applications can now obtain a performance boost by configuring the service registration of their DbContext types to use a pool of pre-created instances, avoiding the cost of creating new instance for every request. Try adding the following code to your Startup/ConfigureServices to enable DbContext pooling:
You can read more information about the updates included in Entity Framework Core 2.0 online in their announcement post.
Monitor and Profile with No Code Changes and Application Insights
ASP.NET Core 2.0 runs with no modifications necessary on Azure App Service and comes with integrations that provide performance profiling, error reporting, and diagnostics from Azure Application Insights. In Visual Studio 2017, right-click on your project and choose “Add – Application Insights Telemetry” to start collecting data from your application. You can then review the performance of your application including all log messages directly within Visual Studio 2017.
That’s nice when you’re developing your application, but what if your application is already in Azure? We’ve got support in the Azure portal to start profiling and debugging, and it starts when you first publish your application and navigate to the cloud portal for your new app service. Azure will prompt you with a new purple banner indicating that Application Insights for monitoring and profiling is available

Figure 5 – Banner in Azure Portal offering to assist in configuring Application Insights
When you click through that banner, you will create an Application Insights service for your application and attach those features without recompiling or redeploying. Shortly afterwards, your new Application Insights service will start reporting data about the activity captured.

Figure 6 – Initial Application Insights Overview on Azure Portal
It even shows the number of failed requests and errors in the application. If you click through that area, you’ll see details about the failed requests:

Figure 7 – Failed Requests Report on Azure Portal
There is a System.Exception thrown, and identified at the bottom of the screen, if we click through that reported exception, we can see more about each time that exception was thrown. When you click through a single instance of those exceptions, you get some neat information about the exception including the call stack:

Figure 8 – Exception Analysis in the Azure Portal
Snapshot debugging in Application Insights now supports ASP.NET Core 2.0. If you configure snapshot debugging in your application, then the “Open Debug Snapshot” link at the top will appear and show the complete call stack and you can click through method calls in the stack to review the local variables:
Nice! We can go one step further and click that “Download Snapshot” button in the top corner to start a debug session in Visual Studio right at the point this exception was thrown.
What about the performance of these pages? From the Application Insights blade, you can choose the Performance option on the left and dig deeper into the performance of each request to your application.

Figure 11 – Application Profiling in Azure Portal
There are more details available in our docs about performance profiling using Application Insights.
If you want the raw logs about your application, you can enable the Diagnostic Logs in App Service and set the diagnostic level to Warning or Error to see this exception get thrown.

Figure 12 – Configure Logging within the Azure Portal
Finally, choose the Log Stream on the left and you can watch the same console that you would have on your developer workstation. The errors and log messages of the selected severity level or greater will appear as they are triggered in Azure.

Figure 13 – Live Console Logging inside the Azure Portal
All of the Application Insights features can be activated in ASP.NET Core without rebuilding and deploying. Snapshot debugging requires an extra step and some code to be added, and the configuration is as simple as an extra NuGet package and a line in your Startup class.
You can learn more about Application Insights Telemetry in our online documentation.
Razor Support for C# 7.1
The Razor engine has been updated to work with the new Roslyn compiler and that includes support for C# 7.1 features like Default Expressions, Inferred Tuple Names, and Pattern-Matching with Generics. To use C #7.1 features in your project add the following property in your project file and then reload the solution:
<LangVersion>latest</LangVersion>
C# 7.1 is itself in a preview state, and you can review the language specification for these features on their GitHub repository.
Simplified Application Host Configuration
Host configuration has been dramatically simplified, with a new WebHost.CreateDefaultBuilder included in the default ASP.NET Core templates that automatically allocates a Kestrel server that will attempt to run on IIS if it is available, and configures the standard console logging providers. Your Program.cs file is simplified to only this content:
That reduces the possibility of accidentally breaking some of the standard configuration that most developers were not altering in their ASP.NET Core applications. Why make you write the same boilerplate code over and over, when it could be simplified to 3 lines of code?
Summary
These updates in ASP.NET Core 2.0 provide new ways to write your applications and simplify some of the operational process of managing a production application. A word of thanks to our .NET Community for their feedback, issues, and contributed source code on GitHub. They’ve really been a huge help in delivering this new version of ASP.NET Core. We encourage you to download the latest .NET Core SDK from https://dot.net/core and start working with this new version of ASP.NET Core. You can watch the launch video for .NET Core 2.0 and ASP.NET Core 2.0 at: https://aka.ms/dotnetcore2launchvideo
Excellent! Than you! However, the .NET Core Windows Server Hosting bundle experience needs some improvements. Just tried to install the ASP.NET Core 2.0 module and the .NET Core 2.0 runtime on a Windows Server 2012 R2 box just to figure that the Windows Server Hosting (x64) installer for .NET Core 2.0.0 runtime (Current) (https://www.microsoft.com/net/download/core#/runtime) neither includes the ASP.NET Core module nor the runtime. Of course, nowhere is documentation that one needs to install the (outdated ASP.NET Core 1.1 module) Windows Server Hosting (x64) for .NET Core 1.1.2 runtime (LTS) package and Windows (x64) Installer for .NET Core 2.0.0 runtime (Current) to get ASP.NET Core 2.0 Web apps running on IIS in Windows Server 2012 R2. Hope you guys get that sorted out soon. And while you’re working hard to get it done, please add file checksums for the Windows Server Hosting packages at https://dotnetcli.blob.core.windows.net/dotnet/checksums/2.0.0-runtime-sha.txt as well. Thank you!
Just to be clear, are you saying that the following must be installed on a web server for it to host ASP.NET Core 2 web applications:
– .NET Core 1.1.x runtime
– .NET Core 2.0.x runtime
– Windows Server Hosting for .NET Core 1.1.x runtime
– Windows Server Hosting for .NET Core 2.0.x runtime
All of which are available at https://www.microsoft.com/net/download/core#/runtime ?
We’ve fixed the links! Thanks for the report.
Don’t you think it would be helpful to indicate how UseCookieAuthentication is totally broken? Also social logins? The basic templates in the tooling don’t even show what the new world is supposed to look like.
See the following doc for guidance on addressing breaking changes to cookie and social login auth: https://docs.microsoft.com/aspnet/core/migration/1x-to-2x/identity-2x.
Read https://github.com/aspnet/Security/issues/1310
Agreed. Probably more crazy frustrating is that all the Identity stuff is broken. Even if you look at the new template, it still includes all the older 1.1 support. Then EF 2.0 stuff breaks also. I used to tell folks I liked Microsoft tools because everything just “worked” when updates occur. Not so much any more.
So, I really don’t think I can easily upgrade to Core 2.0 as it will mean I have to learn how all the new .NET Identity stuff is supposed to work, without really any documentation or template examples.
Bravo!! Can’t wait to use the new stuff!
Where knockout SPA template?
Thanks for the new features and asp.net core 2.0
Awesome stuff fellows!
Cool updates. Thanks Jeff!
Can you help me with setting up token based authentication for web api2 using core 2.0? Thanks in advance!
Web API 2 is the old API framework for ASP.NET on the old .NET Framework.
The .NET Core framework uses ASP.NET Core which uses for its API.
For that you would use the Bearer authentication middleware.
I’m ready to move the second SignalR works…
Awesome core 2.0 <3
You made me soo happy with releasing ASP.NET Core 2.0!!!
Is there an easy way to configure Application Insights from Visual Studio Code? If not, making this work would be great!
“ASP.NET Core 2.0 runs with no modifications necessary on Azure App Service […]”
I am running an Azure Web App in West Europe and I cannot get my newly upgraded MVC app to work. It seems as if only the preview tools are installed on the Web App instance.
Is there any way to resolve this? I tried manually installing the Release version of .NET Core 2.0 using Kudu but that didn’t solve the problem.
The Azure regions are coming online with the 2.0 release over the next few days.
Thanks Jeffrey, is there a list somewhere what regions are already running? It’s a little difficult to figure out if the upgrade didn’t go well on my side or my region (East US) doesn’t have .NET core 2. from just getting HTTP Error 502.5 – Process Failure
Is there a way to tell on the app service what .net core version is available? Does the app service need to be recreated?
Is there any way to create a new project with the React.js + Redux template without typescript?
Hi Jeffrey, where is ASP.NET SignalR Core?
SignalR is not part of this release, and will be included in a future release
It seems that https://github.com/aspnet/MvcPrecompilation/pull/148 caused the .PrecompiledViews.pdb file being copied to the publish directory all the time, even if ‘DebugSymbols’ is set to false (false). Unfortunately, does not work here to prevent the file from being published (Web deploy). Maybe you guys can fix in 2.1.0?
or maybe in 2.0.0.1? 🙂
👏👏👏
I tried the new version and it was really cool. thanks for the good job.
There are two paragraphs in this article that end with “this content:” and the image or code that should be shown is missing.
Are not the .NET Core 2.0 part of Visual Studio 2017.3?
Do I need to download something?
Yes, you need to download the SDK separately
Just today I tried out the new ASP.NET Core 2.0 but for some reason the integration layer with Windows Services seems to be broken: IWebHost.RunAsService() method keeps throwing the same non-sensical exception pretty much out of the box.
I must say it is a bit of a disappointment. I had been waiting for Core 2.0 for quite some time hoping it would come close enough to full framework but apparently some gaps are still there, if not in the product then in the default configuration and documentation for sure.
got two errors:
var user = from d in db.Users
where d.userId == session
let coupList = d.Coupons.Where(w => w.expire.Date >= DateTime.Now.Date && !w.isUsed)
select new
{
isMember = d.isMember,
deduction = d.deduction,
coupons = coupList.Any() ? coupList.Sum(s => s.money) : 0, //error: must be reducible node
address = d.address.Split(‘^’), //error: CS0854 C# An expression tree may not contain a call or ……
};
With dotnet core 1.1, it’s all right.
This Razor Pages feature feels very ASPX-y (aka Web Forms). Does this mean that MVC will be deprecated (which I really love) in the future or will this just be another option to it?
Can I use both asp.net core 1.x and asp.net core 2.x in same server ( on IIS ) ? Does the ANCM 1.x supoort asp.net core 2.x? Does the ANCM 2.x support asp.net core 1.x ?
Its awesome to run multiple version on same mechine
Where can we find the PDB of ASP.NET Core 2.0 ?
Please i have downloaded the SDK and installed it, yet vs 2017 community edition not seeing the 2.0. Can you please help in this regard. I am very new to Microsoft technology, so please make it simple and step by step. Please note that I was fairly working on the 1.1 before the 2.0 came out. Please help urgently as I do not want my learning to slow down.
Have you installed the Runtime as well? You also need VS version 15.3
“Microsoft.AspNetCore.Builder.ForwardWindowsAuthentication” is no longer present in 2.0? The documentation indicates it is still there: https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.builder.iisoptions but reflecting the assembly in VS shows it has been replace with “AuthenticationDisplayName”. Can we get some explanation of whats going on with that?
It looks like Azure App services is supporting 2.0 – but the Government Azure does not yet. Do you know when the US Government will support this? My code with 2.0 Preview worked in the Azure Government cloud – but failed to start once I upgraded to RTM 2.0.
Thanks
Thanks Jeff – Very Nice!
> ASP.NET Core 2.0 runs on both .NET Framework 4.6.1 and .NET Core 2.0, so you will need to update your target framework in your project to netcoreapp2.0 if you were previously targeting a 1.x version of .NET Core.
Questions:
1. Why talk about .NET Framework 4.6.1 rather than .NET Framework 4.7, given that 4.7 is the newest version of full framework as of this announcement? Shouldn’t everyone be encouraged to use the newest full framework version?
2. How do you reference .NET Core 2.0 in a .NET Framework 4.6.1 project? The example shows how to change the targetFramework element when using .NET Core 1.1, but when using .NET Framework 4.6.1 the project file is much more complicated and doesn’t have the targetFramework element.
3. If .NET Core 2.0 also runs on .NET Framework 4.6.1 and above, why aren’t there any project templates that create a .NET Core 2.0 project for .NET Framework 4.6.1?
I’m unsure when to use MVC or Core 2.0 … is Core the future of web development or will MVC get at least the same focus as Core?
If you update the SDK and get loads of unsatisfied-dependency errors then use the VS Code terminal to add the latest SPA template package using the following command
dotnet add package Microsoft.AspNetCore.SpaTemplates –version 1.0.0
Then when prompted to restore packages allow Code to do so. When the dust settles, all will be sweetness and light.
I created a netcore 2.0 app in VS2017 and using the publish to a folder feature found that it was unacceptably slow (over ten minutes). It was even worst publishing to Azure Web App.
Just to make sure it wasn’t my app, I created an asp netcore 2.0 Empty template app using VS2017 and publish to a folder and it took three minutes. The same empty template app in .Net publish to a folder took only a few seconds.
I tried to tweak the settings (e.g. delete all files) but no change. Any suggestions on how to improve Publish performance?