Posted by Anuraj on Sunday, October 26, 2014 Reading time :4 minutes
ASP.Net vNext is the next version of ASP.Net Framework. As part of ASP.NET vNext, the MVC, Web API, and Web Pages frameworks are being merged into one framework, called MVC 6. The new framework removes a lot of overlap between the existing MVC and Web API frameworks.
ASP.Net vNext Features.
ASP.NET vNext is not backwards compatible with existing ASP.NET applications. However, the current frameworks (Web Forms 5, MVC 5, Web API 2, Web Pages 3, SignalR 2, and Entity Framework 6) will continue to ship in Visual Studio, and will be fully supported in ASP.NET vNext.
Creating Hello World application in ASP.Net vNext
Select the ASP.NET vNext Empty Web Application template, name the project HelloWorld, and click OK.
One of the vNext feature was it is lean, Microsoft has re-written the Framework and project / solution structure. You will not find the web.config, *.csproj files.
* Project.json - The project.json file contains a list of dependencies for the project and a list of build output configurations. It can also include a list of commands.
Dependencies section lists all the dependencies of your application. These are defined by name and version, the runtime loaders will determine what should be loaded. Frameworks section lists target frameworks that will be built, and dependencies that are specific to the configuration. This snippet will build for Desktop (aspnet50) or Core CLR (aspnetcore50). You can find more details about the Project.json schema from github link. Frameworks you can configure using Project property pages, by default application will be using ASP.Net 5.0 Framework. Once you change the Active Target Framework, Visual Studio will update the references appropriately.
**Active Target Framework is ASP.Net**
**Active Target Framework is ASP.Net Core**
* Startup.cs - By default, the vNext hosting environment expects to find a startup class named Startup. This class must contain a Configure method that takes an IBuilder parameter, and you configure the HTTP pipeline inside this Configure method. The empty project creates the class with nothing in the Configure method. If you were worked in Owin / Katana project, Startup.cs is similar to Owin Startup file. This is the default Startup.cs file for empty vNext application.
To enable MVC in the HTTP pipeline you’ll add a NuGet package and configure the Startup class.
Once you save the changes, Visual Studio will detect the changes and download the required nuget packages (You can find the details from output window).
If you didn’t add the using Microsoft.Framework.DependencyInjection, you won’t get services.AddMvc() method. The AddMvc method adds the MVC framework services to the dependency injection system. The UseMvc method configures MVC default settings such as routes.
Next create a folder called Controller and add a controller class, HomeController.cs. Also create Home folder inside Views folder, and add a razor view - Index.cshtml. (You won’t get option like Add View by right clicking on Controller method.)
Press F5 to start the application. voilÃ , you have created your first HelloWorld ASP.Net vNext application.
In the next post I will discuss about deployment. Happy Programming :)