WiseJ – Pixel Perfect Web Applications

If your a .NET developer, take a look at WiseJ for your Web Application development.

http://wisej.com/

It allows you to:
– Create complex Web Applications in a fraction of the time compared to traditional ASP.NET or MVC.
– C# and VB.NET developers are productive right away using a well-established environment and programming paradigm.
– Integrate most third party JavaScript widgets in a standard and consistent framework – easier to maintain and deploy.
– Live Theme Builder
– Pixel Perfect Designer
Design and build complex Web Applications directly in Visual Studio using C# or VB.NET and a rich library of components.

.NET Standard Library Support for Xamarin

Today, we are extremely pleased to release support for .NET Standard Libraries for all Xamarin applications. This includes creating and consuming local .NET Standard Libraries, but also adding .NET Standard Libraries from NuGet directly to your Xamarin apps. It’s now easier than ever to share code across all .NET platforms, including the recently introduced .NET Core and ASP.NET Core platforms.

What is .NET Standard?

The .NET Standard Library is a formal specification of .NET APIs that are intended to be available on all .NET runtimes. You can think of it as a simplified, yet expanded, Portable Class Library. It is a single library with a uniform API for all .NET Platforms including .NET Core. You just create a single .NET Standard Library and use it from any runtime that supports .NET Standard Platform.

NetStandard

Consuming .NET Standard NuGets & Assemblies

A lot of libraries have recently added .NET Standard support, enabling them to support .NET Core applications. It’s now possible to add a NuGet to Xamarin applications that supports .NET Standard in both Xamarin Studio and Visual Studio. For instance, here’s the preview release of Windows Azure Storage that supports .NET Standard 1.6:

NuGet

As you can see, it targets the Standard library. Xamarin Studio and Visual Studio will simply add the reference to the netstandard folder when the NuGet is installed:

AzureStorage

Getting Started with .NET Standard

To create or consume .NET Standard libraries in your Xamarin applications, ensure that you’re running Visual Studio 2015 Update 3 and are updated to Xamarin 4.1.2 for Visual Studio in the Stable release channel.

In Visual Studio, File->New Project and select the standard Portable Class Library (PCL) template located in the “Visual C#” section.

AddNewPCL

This PCL now needs to be upgraded to target the .NET Standard Library, which can be found in the projects properties.

RetargetPCL

This will change the project type and the APIs that the project can access. netstandard currently has seven versions of API coverage. Below is a useful chart to guide you through what platforms support which APIs. This can be adjusted any time in the project properties, similar to how you can change the Profile of a PCL after creating it.

Platforms

Finally, simply add the new .NET Standard Library to any Xamarin project just like any other reference!

The ability to create .NET Standard Libraries in Xamarin Studio on macOS will be available in the future, but today we are pleased to release Xamarin Studio 6.0.2 which supports consuming and compiling these libraries.

Learn More

For a full breakdown of .NET Standard Libraries, including a full comparison to Portable Class Libraries, be sure to read through the official .NET Standard Library documentation.

The post .NET Standard Library Support for Xamarin appeared first on Xamarin Blog.

Creating Animations with Xamarin.Forms

Animations are a great way to add polish to your user interface and make your app stand out. Xamarin.Forms includes its own animation infrastructure that allows for easy creation of simple animations, while also being versatile enough to create complex animations. The Xamarin.Forms animation classes target different properties of visual elements, with a typical animation progressively changing a property from one value to another over a period of time. Note that there is no XAML interface for the Xamarin.Forms animation classes. However, animations can be encapsulated in behaviors and then referenced from XAML.

In this blog post, I’m going to explore creating and cancelling animations using the ViewExtensions class in Xamarin.Forms to create compelling animations that run on iOS, Android, and Windows.

Introduction to Animation

The ViewExtensions class provides a number of extension methods that can be used to create simple animations that rotate, scale, translate, and fade VisualElementinstances. By default, each animation takes 250 milliseconds. However, a duration for each animation can be specified when creating the animation.

The extension methods provided by the ViewExtensions class are TranslateTo, ScaleTo, RelScaleTo, RotateTo, RelRotateTo, RotateXTo, RotateYTo, and FadeTo. Each method is asynchronous and returns a Task<bool> object. The return value is false if the animation completes, and true if the animation is cancelled. The animation methods should typically be used with the await operator, which makes it possible to easily determine when an animation has completed. However, if there’s a requirement to let an animation complete in the background, then the await operator can be omitted. In this scenario, the animation extension methods will quickly return after initiating the animation, with the animation occurring in the background.

The ViewExtensions class also includes a CancelAnimations method that can be used to cancel any animations.

Performing Simple Animations

Each extension method in the ViewExtensions implements a single animation operation that progressively changes a property from one value to another value over a period of time.

Rotation

The following code example from the sample application demonstrates using the RotateTo method to animate the Rotation property of an Image:

await image.RotateTo (360, 2000);

This code animates the Image instance by rotating up to 360 degrees over 2 seconds (2000 milliseconds). The RotateTo method obtains the current Rotation property value for the start of the animation, and then rotates from that value to its first argument (360).

In addition, Xamarin.Forms supports relative rotation and rotation with anchors. For more information, see Relative Rotation and Scaling and Rotation with Anchors.

Scaling

The following code example from the sample application demonstrates using the ScaleTo method to animate the Scale property of an Image:

await image.ScaleTo (2, 2000);

This code animates the Image instance by scaling up to twice its size over 2 seconds (2000 milliseconds). The ScaleTo method obtains the current Scale property value (default value of 1) for the start of the animation, and then scales from that value to its first argument (2). This has the effect of expanding the size of the image to twice its size.

In addition, Xamarin.Forms supports relative scaling and scaling with anchors. For more information, see Relative Scaling and Scaling and Rotation with Anchors.

Translation

The following code example from the sample application demonstrates using the TranslateTo method to animate the TranslationX and TranslationY properties of an Image:

await image.TranslateTo (-100, -100, 1000);

This code animates the Image instance by translating it horizontally and vertically over 1 second (1000 milliseconds). The TranslateTo method simultaneously translates the image 100 pixels to the left, and 100 pixels upwards. This is because the first and second arguments are both negative numbers. Providing positive numbers would translate the image to the right, and down.

Fading

The following code example from the sample application demonstrates using the FadeTo method to animate the Opacity property of an Image:

await image.FadeTo (1, 4000);

This code animates the Image instance by fading it in over 4 seconds (4000 milliseconds). The FadeTo method obtains the current Opacity property value for the start of the animation, and then fades in from that value to its first argument (1).

Cancelling Animations

An application can cancel one or more animations with a call to the static ViewExtensions.CancelAnimations method, as demonstrated in the following code example from the sample application:

ViewExtensions.CancelAnimations (image);

This will immediately cancel all animations that are currently running on the Image instance.

Compound Animations

It’s also possible to create sequential animations with subsequent animation methods executing after the previous method has completed. These can be created with theawait operator, as demonstrated in the following code example from the sample application:

await image.TranslateTo (-100, 0, 1000);    // Move image left
await image.TranslateTo (-100, -100, 1000); // Move image up
await image.TranslateTo (100, 100, 2000);   // Move image diagonally down and right
await image.TranslateTo (0, 100, 1000);     // Move image left
await image.TranslateTo (0, 0, 1000);       // Move image up

In this example, the Image is translated over 6 seconds (6000 milliseconds). The translation of the Image uses five translation animations, with the await operator indicating that each animation executes sequentially. Therefore, subsequent animation methods execute after the previous method has completed.

Composite Animations

Composite animations can be created by mixing awaited and non-awaited animations and using the Task.WhenAny and Task.WhenAll methods to run multiple asynchronous methods concurrently. Both methods return a Task object and accept a collection of methods that each return a Task object.

The following code example, from the sample application, demonstrates using the Task.WhenAll method to run multiple asynchronous animation methods concurrently:

// 10 minute animation
uint duration = 10 * 60 * 1000;
await Task.WhenAll (
  image.RotateTo (307 * 360, duration),
  image.RotateXTo (251 * 360, duration),
  image.RotateYTo (199 * 360, duration)
);

In this example, the Task.WhenAll method call contains three tasks, each of which executes over 10 minutes. Each Task makes a different number of 360 degree rotations: 307 rotations for RotateTo, 251 rotations for RotateXTo, and 199 rotations for RotateYTo. These values are prime numbers, therefore ensuring that the rotations aren’t synchronized and hence won’t result in repetitive patterns.

The following screenshots show the multiple rotations in progress on each platform:multiple-rotations

Controlling Velocity Changes

The animation extension methods in the ViewExtensions class allow an easing function to be specified as the final method parameter. The easing function, specified by theEasing class, controls how an animation speeds up or slows down as it runs.

The following code example demonstrates specifying different easing functions in a compound animation:

await image.TranslateTo(0, 200, 2000, Easing.BounceIn);
await image.ScaleTo(2, 2000, Easing.CubicIn);
await image.RotateTo(360, 2000, Easing.SinInOut);
await image.ScaleTo(1, 2000, Easing.CubicOut);
await image.TranslateTo(0, -200, 2000, Easing.BounceOut);

By specifying an easing function for an animation, the animation velocity becomes non-linear and produces the effect provided by the easing function. For example, theBounceIn easing function bounces the animation at the beginning, the CubicIn easing function slowly accelerates the animation, and the SinInOut easing function smoothly accelerates the animation at the beginning and smoothly decelerates the animation at the end.

Omitting an easing function when creating an animation causes the animation to use the default Linear easing function, which produces a linear velocity.

In addition, custom easing functions can be created. For more information, see Custom Easing Functions.

Wrapping Up

The ViewExtensions class provides extension methods that can be used to create simple animations that rotate, scale, translate, and fade VisualElement instances. In addition, the ViewExtensions class also includes a CancelAnimations method that can be used to cancel any animations.

The animation extension methods in the ViewExtensions class also allow an easing function to be specified as the final method parameter. The easing function, specified by the Easing class, controls how an animation speeds up or slows down as it runs.

For more information, see Animation.

The post Creating Animations with Xamarin.Forms appeared first on Xamarin Blog.

Build C# and F# Apps on Your iPad with Continuous Mobile Development Environment

It doesn’t matter if you’re on a Windows or a macOS machine, you have access to amazing IDEs to build iOS, Android, Mac, and Windows apps and libraries with Visual Studio and Xamarin Studio. But, what if you could take all of your code on the go and with you everywhere you go? What if you could open up a code file, library, or Xamarin.Forms project on your iPad and start coding with a full professional mobile development environment with IntelliSense powered by Roslyn? That’s the experience that Frank Krueger, Xamarin MVP, delivers with his new app, Continuous Mobile Development Environment, a professional C# and F# IDE for your iOS devices.

continuous_app

Built with Xamarin

Frank Krueger has been developing apps with Xamarin since it first came out. He’s seen great success as an independent developer with apps including iCircuit and Calca.Continuous demonstrates the full potential that’s unlocked for .NET developers through Xamarin, with full API access across all platforms and the power of .NET.

Powered by Open Source

Powered by the open source .NET compiler platform as a service Roslyn, Continuous offers full syntax highlighting and code completion as well as documentation for over 60,000 symbols. Krueger was able to deliver rich F# support with the open source FSharp Compiler, and to bring Continuous full circle and deliver support for .NET’s standard library, all iOS APIs, and support for Xamarin.Forms, it leverages Mono and the now open sourced Xamarin.iOS and Xamarin.Forms. It’s amazing to see what can be built with these open source technologies!

code_completion

Professional Development Environment

As a professional development environment, Continuous is lightning fast, has an interactive output window to see your app running live, automatic and constant debugging, and works completely offline. If that wasn’t enough, Continuous deeply integrates into iOS features and has a custom keyboard accessory for quick access to much needed keys for C# and F# development. Continuous doesn’t stop there, though—it also enables developers to carry on development in your favor desktop IDEs, Visual Studio and Xamarin Studio. You can share a single file, zip an entire solution, or collaborate with other iOS apps to synchronize with Git.

Try Continuous Yourself

You can learn more about Continuous at continuous.code and learn more about its development and release on Krueger’s blog. We want to congratulate Frank on his release of Continuous; we can’t wait to see what he and all developers building apps with Xamarin come up with next. To learn more about all of the open source projects at Xamarin, visit open.xamarin.com

The post Build C# and F# Apps on Your iPad with Continuous Mobile Development Environment appeared first on Xamarin Blog.

Explore iOS 10, tvOS 10, watchOS 3, and macOS Sierra Previews Today

Apple announced major updates to all of their operating systems and a smattering of new APIs for developers to explore at this year’s WWDC conference. sdk-icon-90x90_2xWe are excited for Xamarin developers to get their hands on these new APIs to start building beautiful native apps in C#, so today, we’re releasing our first set of previews for developers to start exploring iOS 10, tvOS 10, watchOS 3, and macOS Sierra along with supporting Xamarin-specific documentation to get you started.

iOS 10

iOS 10 has something for everyone. SiriKit unleashes the power of Siri for developers to integrate unique experiences into their mobile applications to enhance a slew of services. Notifications have been completely overhauled to schedule notifications based on geo-fencing or time and a new UI framework to allow enhanced customization has been added. This is just that start, as there are new APIs unlocked in HealthKit, HomeKit, Core motion, Foundation, Core Data, and many more as well. To get started, browse through our Introduction to iOS 10documentation.

ios_overview_2x

tvOS 10

Bring your apps to life on the big screen with the latest additions to tvOS including ReplayKit to live broadcast game play, PhotoKit to share photos with iCloud Photo Library and your apps, and easily integrate multipeer connectivity to your iOS apps. To get started, check out our Introduction to tvOS 10 documentation.

watchOS 3

Take advantage of the latest watchOS release, which dramatically speeds up performance and navigation of all apps. Performance is one thing, but there are also several new APIs to play with, including Fitness and Motion with access to real-time heart rate data, gyroscope, and accelerator. Enhance your existing apps with direct access to the Digital Crown, speaker audio, in-line video, SpriteKit, SceneKit, Apple Pay, and camera data from HomeKit-enabled accessories! You can get started today with our Introduction to watchOS 3 documentation.
watchos3

*This initial release of watchOS 3 has a subset of the final APIs that will be available in the future.

macOS Sierra

hero-macos_medium_2xThese Apple previews aren’t just about mobile devices, as you can also start integrating the latest APIs in macOS Sierra (10.12) into your Xamarin.Mac applications. Our Introduction to macOS Sierra documentation is a great place to start.

Installing the Previews

You can download the Previews for Xamarin Studio on macOS directly from the Xamarin Developer site for each OS: iOS 10tvOS 10watchOS 3, and macOS Sierra. You will need to ensure that you have the latest Xcode 8 Beta installed, which can be run on macOS 10.11.5 (El Capitan) or newer for iOS, tvOS, and watchOS, and macOS Sierra for macOS Sierra development. Upcoming previews will add even more support for these platforms, including support for Visual Studio.

The post Explore iOS 10, tvOS 10, watchOS 3, and macOS Sierra Previews Today appeared first on Xamarin Blog.

Announcing ASP.NET Core 1.0

The first version of ASP.NET 1.0 came out almost 14 years ago. Since then many developers have used it to build and run great web applications, and over the years we have added and evolved many, many capabilities to it.

Today we are excited to announce the release of ASP.NET Core 1.0! This new release is one of the most significant architectural updates we’ve done to ASP.NET.  As part of this release we are making ASP.NET leaner, more modular, cross-platform, and cloud optimized.  ASP.NET Core is now available, and you can start using it today by downloading it here.

ASP.NET Core is an open source web framework for building modern web applications that can be developed and run on Windows, Linux and the Mac. It includes the MVC framework, which now combines the features of MVC and Web API into a single web programming framework.  ASP.NET Core is built on the .NET Core runtime, but it can also be run on the full .NET Framework for maximum compatibility.

We challenged everything instead of delivering an incremental update so you can have an extremely modular, fast and lightweight platform perfect for the new era of software development where monolithic applications are replaced by small, autonomous services that can be deployed individually. All of that while keeping and extending what .NET is best for: developer productivity, and modern languages and libraries.

With ASP.NET Core we are making a number of architectural changes that makes the core web framework much leaner (it no longer requires System.Web.dll) and more modular (almost all features are now implemented as NuGet packages – allowing you to optimize your app to have just what you need).  With ASP.NET Core you gain the following foundational improvements:

  • Build and run cross-platform ASP.NET apps on Windows, Mac and Linux
  • Built on .NET Core, which supports true side-by-side app versioning
  • New tooling that simplifies modern Web development
  • Single aligned web stack for Web UI and Web APIs
  • Cloud-ready environment-based configuration
  • Built-in support for dependency injection
  • Tag Helpers which makes Razor markup more natural with HTML
  • Ability to host on IIS or self-host in your own process

The end result is an ASP.NET that you’ll feel very familiar with, and which is also now even more tuned for modern web development.

This is a 1.0 product which means it is just the beginning and does not have all the functionality of ASP.NET 4.x stack. For example, features like SignalR and Web Pages will come later in the year and other features like Web Forms which are deeply tied to System.Web will remain in the .NET 4.x framework. If you are an existing ASP.NET 4.x developer do not feel rushed to move to ASP.NET Core, we still plan to update Web Forms, MVC, Web Pages, SignalR on .NET 4.x as well.

If you are not a .NET developer, now it’s a great moment to try it. You can enjoy the productivity and power of .NET with no constraints, on any OS, with any tool and for any application. All of that fully open source, developed with the community and with Microsoft’s support.

Get Started Now

There are several places you can go to get a copy of ASP.NET and get started.  You can start with the https://dot.net/core website to download the latest version of .NET framework and tools for your operating system. If you’re using Visual Studio 2015, you can install the new Visual Studio SDK and get started right away. If not, choose one of the downloads for the .NET Core SDK on Windows, Mac or Linux.  Then, download the web development tools for your preferred editor and you can start building web applications with ease.

Visual Studio 2015

Once you have installed the Visual Studio 2015 tooling, you can start building a new ASP.NET Core Application with the standard File -> New Project and choosing an ASP.NET Core template from the collection of C# Web templates:

Visual Studio 2015 New Project

Note that there are three templates for Web projects:

  • NET Web Application – the ASP.NET application templates you’ve known and used
  • NET Core Web Application (.NET Core) – This will start you with a cross-platform compatible project that runs on the .NET Core framework
  • NET Core Web Application (.NET Framework) – This starts a new project that runs on the standard .NET Framework on Windows.

With a destination folder location defined at the bottom, I can click OK and will be greeted by a second set of web application template choices:

ASP.NET Core Templates

This determines which features in ASP.NET Core are initially configured in my new application.  The ‘Empty’ template will start with nothing except some middleware that outputs the text “Hello World”. The WebAPI template starts with a Controller class that will allow you to respond to RESTful requests at the /api/Values endpoint.  Finally, the Web Application template will give you an MVC framework enabled project with some Razor views, the bootstrap CSS framework and jQuery library installed.  The homepage for this application looks like the following by default:

ASP.NET Core Default Web Application

The starter template is responsive, with a simple carousel at the top and some details at the bottom of the initial home page to give you some tips and information about how you can further develop your new ASP.NET Core Web Application.

dotnet Command Line

You can also start new a .NET web application from the dotnet command line interface on any platform.  Simply execute the following command:

dotnet new -t web

This will generate a basic web application with C#, similar to the web application template in Visual Studio 2015.  There are other templates available from the command-line for C# including: console, lib, and xunittest. With the results of any ‘dotnet new’ command, you can run the project immediately by executing the following two commands:

dotnet restore
dotnet run

In the case of web applications, you will have to open the browser and navigate to the URL reported by the dotnet tool.

As this command-line tool evolves, we will add more templates and language support.

Yeoman

The earlier referenced Yeoman templates are available for you to use at the command-prompt as well.  Once the templates are installed, you can start building a C# application by executing:

yo aspnet

This command will present a menu where you can choose from a number of templates that are very similar to the templates that are available in Visual Studio 2015:

Yeoman Template Menu

After choosing a template, Yeoman will restore any npm and bower resources that are referenced and you can launch your new application with the dotnet commands:

dotnet restore
dotnet run

There are a number of file-templates that come with the yeoman ASP.NET Core templates.  These can be used to generate controllers, views, and other ASP.NET files that you may want to create. You can find a complete list of those templates with their usage documented on theYeoman ASP.NET Generator repository.

Features

ASP.NET Core is a reinvention of the ASP.NET web frameworks. From the beginning of ASP.NET in 2002 the .NET server-side frameworks have been built around the concepts of modules, handlers, and integration with Internet Information Server (IIS) on Windows.  With ASP.NET Core, we have rewritten the web framework and .NET framework to better enable a modern web development experience and provide a baseline to build the next 15 years of server development.  By removing modules and handlers, which are IIS concepts, we can make ASP.NET Core run great on other web servers like Nginx and even in your own hosted application.  All application development for ASP.NET Core is built around a new middleware definition and a Controller-centric approach.

Cross Platform Support

CooperationASP.NET Core was built with other operating systems besides Windows in mind.  If you want to share code with teammates that prefer to work on Mac OS X or Linux, ASP.NET Core will allow you to collaborate with those developers and deliver the same experience with our web frameworks when targeting.NET Core.  If you and your team prefer to use Windows for all of your development, you can choose to do that as well.  ASP.NET Core enables you to work with your development team where they prefer working, and that makes everyone happy.

Visual Studio 2015 on Windows is the premier tool for creating, managing, and debugging your ASP.NET Core applications, but you can get started on any platform with Visual Studio Code.  Visual Studio Code is a lightweight text editor with plugins that support editing ASP.NET Core applications.  Additionally, it comes with plugins to manage your interactions with a Git source control provider and to Debug your ASP.NET Core applications on any operating system.

What about Containers?  ASP.NET Core now supports running in containers, with options available on hub.docker.com for Linux and Windows based containers to host your applications.

Open Source – Source Code and Documentation

ASP.NET Core was born on the web and will be built on the web, with all source code available in our GitHub repositories.  You can navigate to the source code by starting at the https://github.com/aspnet/home repository.

You are welcome to download any and all source code and tinker with it, make any change you would like.  If you build something that works, you can submit a pull-request and we will review your changes and consider merging it.  Your code will go through the same tests and reviews that Microsoft engineer’s code will go through. We decided to make all of .NET full open source because we understand that the .NET Community is a large vibrant group of technologists that has a stake in the direction of .NET.  In 2016, all of the modern web stacks are open source and we wanted .NET on equal footing with those other tools on the market.

The documentation is open source as well.  You can find the documentation for ASP.NET Core at https://docs.asp.net and each article has an “Edit this page” link on the top.  If you can improve an article, click that edit button and submit your changes.  Our documentation team will review your changes and may merge them into the document.

Edit on GitHub

There’s a brand new documentation site for all of .NET accessible at docs.microsoft.com/dotnet where you can learn about all of .NET Core and ASP.NET Core.  All of that content is open source as well.

Full Support for the Framework

With the change to an open source .NET, you still get great support for the framework and tools that you use.  We will provide a 3-year support lifecycle for each major and minor version release.  Major releases are indicated by a change to the major version number (1.0.0 is updated to 2.0.0) and minor releases are indicated with a change to the minor version number (1.0.0 is updated to 1.1.0)

More information about the support policy along with a placeholder for when each version, including the 1.0 release candidates, will go out of support are listed on the .NET Core Support Factsheet.

Use Only What You Need

In previous versions of the ASP.NET tools, you would have to reference libraries from the base class library in the GAC.  This would result in many libraries getting loaded into memory, like System.Windows.Forms, that weren’t really needed for your web application to generate HTML to deliver to a web visitor.  The new model will include only the framework references you need, and those references will be added as NuGet packages.

By using a NuGet package approach to managing dependencies in your project, we can deliver updates and patches to the framework through our NuGet package manager as updates and patches are ready.  Additionally, the framework can be deployed with your application in the same destination folder.  In this way, your application will not be affected by an update to the host operating system because it will continue to reference its local copy of the .NET framework libraries that it needs.

Performance

With a significant rewrite of the web framework, we addressed some performance issues and have set aggressive goals for the future.  We’re introducing the new Kestrel web server that runs within your IIS host or behind another host process.  Kestrel has been designed from the start to be the fastest .NET server available, and our engineers have recorded some benchmarks to prove it.  With the backdrop of the standard TechEmpower Benchmarks, the team used these same tests to validate the speed of Kestrel and have some impressive numbers to report:

Scenario Windows Linux
Plaintext 5.12 4.25
Json .84 .95
Mvc/Plaintext 1.2 1.02
Mvc/Json .37 .42

Values Reported are in Millions of Requests Served per Second

The first two tests use middleware to process and handle the TechEmpower test scenarios directly, while the last two tests use MVC to respond to the test scenarios.  These results have been submitted to TechEmpower and will be part of their 13th round of web performance tests.

From these numbers, the Kestrel server can handle more than 5 million requests per second, and that’s good enough for a top 10 finish among the available servers. This is our first published benchmark for these tests, and we’re going to continue improving these numbers.  If you’re interested in learning more about how we calculate these numbers or run the tests, we’ve published our source code in theASPNet/Benchmarks repository.

Dependency Injection Everywhere

ASP.NET Core comes with Dependency Injection enabled.  You’re not required to use it, but we have heard from many developers that they would prefer to have their code activated with dependency injection capabilities enabled.  For those not familiar with Dependency Injection, it is a design pattern that allows the dependencies of one class to be injected as objects are required in your application.  A common technique is to inject dependencies into a class through a constructor, and when a framework like ASP.NET Core is managing the construction of your controllers and other objects you typically cannot manage this process.

With ASP.NET Core, we are delivering a Dependency Injection container that you can use to define the dependencies that should be injected into your controllers, views, or any other class that the framework will create for you. You can get started configuring the container with the ConfigureServices method in the Startup.cs file.

public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSingleton(Configuration);
}
view rawstartup.cs hosted with ❤ by GitHub

In this method, I added the call to AddSingleton(Configuration) in order to make my application’s configuration available throughout the application.  Any class that adds a constructor with a parameter of type IConfigurationRoot will be provided the contents of the Configuration property in my Startup class.  I can even enable Razor views to have dependencies injected by using the @inject directive:

@using Microsoft.Extensions.Configuration
@inject IConfigurationRoot Config
@{
ViewData[Title] = Home Page;
var env = Config[ASPNETCORE_Environment];
}
view rawindex.cshtml hosted with ❤ by GitHub

The Config object will be populated by an IConfigurationRoot type object, as defined and inserted in my ConfigureServices method.  I can then read values from the configuration by using a text-based indexer, in this case to grab the ASPNETCORE_ENVIRONMENT value.

If you’d like a container with more advanced features than our default container, there are other dependency injection containers available onNuGet that you can add to your project.  More information about dependency injection in ASP.NET Core is available in the docs.

Standard Logging is a Snap

We know that application logging is a necessity in server-side applications, and we made logging capabilities a native part of the framework. In ASP.NET Core, there is a default ILoggerFactory object created and made available to you in the Startup class’s Configure method:

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection(Logging));
loggerFactory.AddDebug();
}
view rawstartup.cs hosted with ❤ by GitHub

The default logger will log information to the console based on the configuration defined in the ‘Logging’ section of appsettings.json  There are several log severity levels defined, and this code shows that it will log anything of Debug severity or greater to the console.  The log levels available are:  Information, Trace, Debug, Warning, Error, and Critical.   With the dependency injection feature, you can have access to a logger by adding an ILogger parameter to the constructor of any class and create a logger object from there: �

public class HomeController : Controller {
public HomeController(ILogger<HomeController> logger) {
Logger = logger;
}
public ILogger Logger { get; }
}

One Framework – Not a Collection of Frameworks

In ASP.NET, we started with a single framework the delivered Web Forms with the familiar .aspx extension.  As the web changed and programming models evolved we added four other frameworks into ASP.NET.  Starting with ASP.NET Core, we are consolidating these frameworks into a single framework that is lighter and initially has the features of MVC and WebAPI. With this merged functionality of MVC and Web API, things are much simpler when you need to introduce cross-cutting concerns with your controller.  No longer do you have to consider different routing, security, or filters for an ApiController compared to an MVC Controller.  All Controller classes now handle requests using a Web API or MVC approach.  Consider the following Controller code:

public class ProductController : Controller {
private readonly ProductRepository _repository;
public ProductController(ProductRepository repository) {
_repository = repository;
}
[Route(/api/Product/{id})]
public Product Get(int id) {
return _repository.Get(id);
}
[Route(/Product)]
public ActionResult Index() {
var allProducts = _repository.GetAll();
return View(allProducts);
}
}

This controller is capable of servicing a Web API GET request, responding on the api/Product route as well as handle a request for the Index page and return with the content of a Razor-based view.  This flexibility allows ASP.NET Core developers to centralize their interactions with their web visitors and reuse logic more easily than they could in prior versions of ASP.NET.

MVC Tag Helpers

With ASP.NET Core, we are also introducing a new way to generate client-side code from .NET and make it easier to re-use in Razor markup.  We call these Tag Helpers and they are referenced in your server-side markup as though they were another HTML tag that you were using. The Razor engine will recognize the tag and execute the relevant .NET Code that corresponds to it. In the default project template, you can see the environment tag helper in use inside the /Views/Shared/_Layout.cshtml file. In Visual Studio 2015, the Razor editor will highlight the use of tag helpers by marking their code in bold purple text.  TagHelpers in Visual Studio 2015Learn more about Tag Helpers in the ASP.NET Docs or you can catch the Channel 9 video discussing the feature.

Built with the Command-Line in mind

ASP.NET Core no longer requires an IDE to compile and run your application.  You can now build your application with the dotnet command line interface.  Visual Studio 2015 and Visual Studio Code provide a nice graphical interface on top of the standard command-line tools.  This way, you can use your favorite editor to write .NET code and get the same compilation results as your friends who prefer Visual Studio.  You will also have the same compilation experience on your continuous integration services that you have on your development workstation. More information about the new .NET Core and .NET Command Line interface released today is covered on the .NET Blog.

Yeoman Generators

We’re also providing baseline templates that work on all environments if you use the Yeoman template tool.  Yeoman is a tool to help you scaffold source code, and we are providing the generator-aspnet package that will help you get a new web application up and running.  Use npm to install Yeoman with the command:

npm install -g yo

Then you can install the templates with

npm install -g generator-aspnet

You can then start building a new ASP.NET Core application with the command:

yo aspnet

The source code for these templates is available on GitHub at: https://github.com/OmniSharp/generator-aspnet

Ready for the Cloud

Many customers have told us that they want to be ‘cloud ready’ and be able to move their server-side applications easily into the cloud.  ASP.NET Core has a number of key features that make it ready for the cloud. We’re delivering a cache provider that runs on Redis, so that you can upgrade your in-memory cache for the cloud when you’re ready to scale out your application to many servers.  Add the Redis cache provider to your project with the Microsoft.Extensions.Caching.Redis package and you can configure the Redis distributed cache provider in your ConfigureServices method with code like the following:

services.AddSingleton<IDistributedCache>(  
  provider => new RedisCache(new RedisCacheOptions  {    
    Configuration = "redis_connectionstring",    
    InstanceName = "myRedisInstanceName"  
  }));

By using the dependency injection container, I can ask for an IDistributedCache object in the constructor of my controllers and work with the contents of the cache based on the value passed in to that constructor.

public HomeController(IDistributedCache cache) {
this.Cache = cache;
}
public IDistributedCache Cache { get; private set; }
public IActionResult Index() {
ViewBag.CachedValue = Cache.Get(myCacheKey);
return View();
}

We have also made significant advances in configuration management of our web applications.  In other frameworks, you might store your database connection information, cloud storage API keys, or other secrets directly in your configuration files. A quick search of GitHub has revealed too many of these keys in the past, and we want to enable you to hide these values while providing a good experience for operations teams that manage the deployment of these secrets to a production environment.  With ASP.NET Core, we’re introducing the SecretManager command-line tool to help you store these values where they won’t be accidentally picked up by your source control tool.

The secret manager is enabled by default in Visual Studio 2015 and dotnet new templates.  If its not enabled in your project, add it to your project by adding this entry to the “tools” section of project.json:

"Microsoft.Extensions.SecretManager.Tools": {
  "version": "1.0.0",
  "imports": "portable-net45+win8+dnxcore50"
}

There will also be an identifier at the top of the default project.json file that indicates the name of the project for the secret manager.  In a sample project.json file, it looked like this:

  "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",

You can then reference the secret values stored by the secret manager by adding a reference to the Microsoft.Extensions.Configuration.UserSecrets package.  In the default templates, there will be an entry in the constructor of the Startup class that loads configuration values from the secret manager:

if (env.IsDevelopment()) {

  builder.AddUserSecrets();

}

This will overwrite any configuration options loaded from a configuration file with the contents of the secret store.  The secret store actually isn’t too secret, its just a set of JSON files hidden in your user profile folder.  If the usersecrets files are not found, this command will fail silently. In Visual Studio 2015, you can access and manage this file’s content directly by right-clicking on the project and selecting the ‘Manage User Secrets’ context menu.  If you are working on the command-line, you can set a value with the command:

dotnet user-secrets set name value

Other options for the dotnet user-secrets command-line tool can be found by calling

dotnet user-secrets -h

More information about the secret manager can be found in the ASP.NET Core docs.

To help with the management of the application on the production space, we’ve introduced an easier way to load configuration through environment variables.  In the previous sample code, you saw a call to env.IsDevelopment()  This is a check that the current environment is named “Development”.  By default, when you debug an application from Visual Studio 2015, an environment variable called “ASPNETCORE_ENVIRONMENT” is set to the value “Development” and ASP.NET Core can interpret that value and make features available to the Development environment only.  If that environment variable is NOT set, ASP.NET Core assumes that you are running in Production.

In the same Startup class’s constructor method, there is a default call to builder.AddEnvironmentVariables()  This applies any configuration values that are stored in environment variables to your application.  You can configure your cloud services or dockerfile to set environment variables appropriate for your application and they will override any prior configuration value provided.

Bundling and Minification

We’re updating our approach for bundling and minification of static web files to use a Visual Studio extension called ‘Bundler and Minifier’  This extension replaces the previous methods of writing ScriptBundle and StyleBundles or using another tool to operate on your files.  With Bundler & Minifier you can right click on the files to concatenate or compress and Visual Studio will act on them appropriately.  The extension will record your actions in a bundleconfig.json file so that your project changes can be synchronized with source control.

You can learn more about the Bundler & Minifier extension on its GitHub repository and from Mads Kristensen on the ASP.NET Community Standup.

Migration from RC2

If you are migrating from the RC2 release, there are a small number of breaking changes that you should be aware of when updating your code.  These are all edge scenarios if you are doing more advanced customization of your application, and should not affect everyone.  Among the changes that you may need to be aware of are:

A detailed list of changes is available in the ASP.NET Announcements Issue List.

What’s Next?

The ASP.NET Core team is moving forward with bringing more web capabilities into the Core framework that we have heard our customers want.  Look for us to start working on a new version of our SignalR real-time web application capabilities that you may have used in prior versions of ASP.NET.   We’re also researching how to bring the ‘Web Sites’ project model from ASP.NET into the Core framework by supporting something we’re calling ‘Controllerless Views’.

To keep up to date on the discussion and direction of ASP.NET Core, make sure you tune in to our team leads weekly video broadcast atlive.asp.net  If you can’t make the live show each Tuesday, then the recordings are made available on the website.  The team reads your comments and will respond.

Should I Switch Today?

We’re excited about the new release of ASP.NET Core, and we think you will be too.  A lot has changed from ASP.NET 4.6 and we think this new product is ready to start taking production workloads.

If you have a new web application to build, try ASP.NET Core.  If you want to build a new application that will be deployed to a Docker Container, try ASP.NET Core.  Perhaps you want to build a micro-service that will be interacting with an existing application, we think you should try ASP.NET Core.

If you have a 10-year old application that your company relies on, we don’t recommend attempting to port it to ASP.NET Core.  We’ve found that the process to move an application from ASP.NET MVC to ASP.NET Core is as significant as the transition from ASP.NET Web Forms to ASP.NET MVC.  We recommend that you look at the switch of an application to ASP.NET Core as a rewrite instead of a migration.

Summary

We’ve made some large changes to the ASP.NET Core product for this release.  If you are using ASP.NET 4.6, you can still use those frameworks and libraries.  They are a hardened toolset that we will continue to support and update, with patches planned for the upcoming “VS15” product.  If you’re building a new application or you need to build an application that runs cross-platform, perhaps in a container, download ASP.NET Core and give it a try.  With our fully open, fully cross-platform .NET framework and libraries there is no reason not to use ASP.NET Core and .NET Core.  The tools will make your job and the performance will make your customers happier.