New features about ASP.NET and C#
💻 coding

New features about ASP.NET and C#

3 min read 538 words
3 min read
ShareWhatsAppPost on X
  • 1ASP.NET vNext allows developers to run applications on non-IIS platforms, enhancing flexibility with Mono support.
  • 2C# 6.0 introduces features like the null propagation operator, simplifying null checks in code.
  • 3RyuJIT compiler enables a smoother workflow by allowing developers to save changes without stopping and rebuilding the application.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"ASP.NET vNext allows developers to run applications on non-IIS platforms, enhancing flexibility with Mono support."

New features about ASP.NET and C#

Microsoft is coming out with a bunch of new features that make me very glad to be a .NET-oriented developer. The ASP.NET vNext platform looks like it is going to be a solid improvement to the environment; no longer will users be tied to IIS or Visual Studio and I anticipate some strong VS competitors coming out with these additions and the official support of Mono. Additionally, the C# 6.0 features are going to make some small changes that will make big impacts.

Roslyn

Roslyn is an open-source .NET compiler platform that will be allowing a ton of language updates that will be coming around with C# 6.0. Since it is also cross-platform, can run using Mono (the open-source implementation of .NET), and will be working side-by-side with the self-server ASP.NET offers, running a .NET web app on a Linux or Mac server is reasonably possible.

Language Change: Null propagation operator

This change adds the operator ‘?.’ in place of ‘.’ to access properties that could possibly be null. So for example, instead of doing this:

if (person != null && person.Address != null && person.Address.City != null) { … }

you can simply do…

if (person?.Address?.City != null) { … }

Since I use Entity Framework relationships a lot, I am really excited about this feature. I am tired of writing null check and null check…

Language Change: Primary constructors and Auto-property initializers

These two features will allow you to setup basic class construction simpler than before. So for example, when we currently do the following:

public class Person {
 public string FirstName { get; set; }
 public string LastName { get; set; }
 public Address Address { get; set; }

 public Person(string firstName, string lastName) {
 FirstName = firstName;
 LastName = lastName;
 }
 public Person(string firstName, string lastName, string city, string state) {
 FirstName = firstName;
 LastName = lastName;
 Address = new Address(city, state);
 }
}

Instead, you can do this now:

public class Person(string firstName, string lastName) {
 public string FirstName { get; set; } = firstName;
 public string LastName { get; set; } = lastName;
 public Address Address { get; set; }

 public Person(string city, string state) : this(firstName, lastName) {
 Address = new Address(city, state);
 }
}

RyuJIT

RyuJIT is a just-in-time compiler that will allow developers to no longer have to stop debugging and re-build; instead, you simply save and refresh. At last, the workflow I love with dynamic languages like Python and PHP (though it already exists with Java, such as in Java Play) is now in ASP.NET. Stopping and rebuilding is, what, a 3 second process? That happens constantly, and builds up to plenty of time and blown concentration.

Self-hosting Applications

No longer are ASP.NET applications confined to IIS and Windows Servers. Now, ASP.NET MVC has a self-hosting tool. This is done using a new Startup.cs file, and will boot up the service:

using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;

public class Startup
{
 public void Configure(IBuilder app)
 {
 app.UseServices(services =>
 {
 services.AddMvc();
 });

 app.UseMvc(routes =>
 {
 routes.MapRoute(
 name: "Default",
 template: "{controller=Home}/{action=Index}/{id?}");
 });
 }
}

There are a ton of more features in the new ASP.NET MVC framework and C# language that will make developers (well, me, anyways) much more productive.

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 23 March 2019 · 3 min read · 538 words

Part of AskGif Blog · coding

You might also like