Getting Started with ASP.Net 5 Cross Platform

The all new version of ASP.Net, ASP.Net5 has raised significant amount of curiosity as well as discussions, even before developers have started using it. It is an open source cross platform framework that is meant to develop cloud based web applications. This all new framework contains modular components which helps you devise customized solutions while maintaining flexibility that ASP.Net5 promises. The best part of this new framework is the cross platform feature which eventually allows you to design solutions across MAC, Windows, and Linux.

Why Go for ASP.Net5?

The first ever ASP.Net was released more than 15 years ago; since then a lot many changes have been included to this framework that has enabled developers to create a lot of web applications. What has changed in ASP.Net5? For one, many architectural modifications have been initiated which has led to a more lean and modular framework. This all new framework includes a set of granular and well factored NuGet packages that help optimize the web app. Gone are the days of system.web.dll. This has been structured keeping in mind the needs of modern web applications. Integrating the web UIs and web APIs with the client side frameworks is easy with this new framework.

The surface area of your application can be reduced for enhanced security as well as improved performance and efficiency. This framework has been initiated keeping in mind the needs of the modern web applications, and their staging requirements. You will see that the environment of this framework is configuration based, and completely cloud ready. As this framework is open source, community interactions help boost the contributions and engagement required for furthering this platform.

Here's what you gain when you use this framework, and the main reason for using it:

  • A modular HTTP request pipeline
  • You can either host it on IIS or self host when using this framework
  • Uses .Net Core which helps achieve app versioning
  • You will get this framework as a NuGet Package
  • You get support to create and use NuGet packages
  • Environment based configuration which makes the framework cloud ready
  • Tools that help towards web app development
  • Community focused development

Now, that you know why ASP.Net, let's try and dissect the application.

The Composition

You can create and run or test the applications for ASP.Net5 using .NetExecution Environment. The application hosting package helps integrate with the project.

Each application is defined using the startup class as shown below

public class Startup
{
     public void ConfigureServices(IServiceCollection services)
     {
     }
     public void Configure(IApplicationBuilder app)
     {
     }
}

The configuration services method used in the code above defines all the services that is being used by your application, while the configure method defines the middleware defines your request pipeline.

Services

Components that are commonly consumed within an application are termed as services, and it is made available through dependency injection. There are three basic services categories used in this framework: scoped, transient and singleton. The services created each time it is being requested are known as transient services.in case a service is not included in the current scope, then scoped services are created. Services created only once, are called singleton services.

Middleware

Whenever you want to create a request pipeline, you need to use a middleware. The middleware here creates an asynchronous logic using HttpContext, and then call upon the next middleware which falls in sequence or terminate the incoming request.

Working with static files, routing, diagnostics, and authentication are some of the prebuilt middlewares that you will find with ASP.Net5

Servers

The hosting model does not take in the requests directly; instead the server implementation surfaces the incoming requests and sends it to the application as a set of features that can be incorporated as HttpContext. You have server support for running an IIS or even for self hosting purposes. In case of Windows, if you don't want to use IIS, you could use Weblistener server based on HTTP.sys

Web Root

The root location for your application from where the HTTP requests are being handled is the web root in case of ASP.Net5. you can configure it using the webroot property present within the project.json file.

Configuration

The name value pairs for the configuration model in ASP.Net5 is neither system.configuration nor web.config. the all new model works along with an ordered set of configuration providers which helps pull out the data required. The built in model supports a wide range of file types. You can even go for a custom configuration provider as below

// Setup configuration sources.
var configuration = new Configuration()
    .AddJsonFile("config.json")
    .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

if (env.IsEnvironment("Development"))
{
    // This reads the configuration keys from the secret store.
    // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
    configuration.AddUserSecrets();
}
configuration.AddEnvironmentVariables();
Configuration = configuration;

Conclusion:

ASP.Net 5 is the all new open source framework to create cross platform web apps. You can create apps across Windows, Mac and Linux, without worrying about configuring the requests or hosting the servers. You can Hire ASP.Net developer to help you get great web apps with the desired interface.

Deepa Ranganathan
  • aspdotnet
  • asp.net5
  • asp.net framework
By Deepa Ranganathan On 04 Jun, 15  Viewed: 247

Other blogs you may like

Integrate Facebook Authentication in ASP.Net5 Web App

Have you recently created a web application using Visual Studio 2015RC? Looking to integrate Facebook authentication to this web application built on ASP.Net5? Then you have hit the right keys and reached the right place. Here, you will use easy steps to integrate Facebook authentication. Now,... By Deepa Ranganathan   On 19 Jun 2015  Viewed: 319

How Bundling and Minification is Done in ASP.Net5?

When ASP.Net 4.5 was launched in the year 2012, you saw two new features- bundling and minification which helped reduce the file size. With these features, you could combined two or more CSS or JS files, and create a single file. The file size of this combined file is reduced with the help of... By Deepa Ranganathan   On 15 Jun 2015  Viewed: 297