6
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.

Getting started with asp.net 5 cross platform

Embed Size (px)

Citation preview

Page 1: Getting started with asp.net 5 cross platform

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.

Page 2: Getting started with asp.net 5 cross platform

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 CompositionYou 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

Page 3: Getting started with asp.net 5 cross platform

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.

ServicesComponents 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.

MiddlewareWhenever 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

Page 4: Getting started with asp.net 5 cross platform

ServersThe 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 RootThe 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.

ConfigurationThe name value pair 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;

Page 5: Getting started with asp.net 5 cross platform

ConclusionASP.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 an ASP.Net developer to help you get great web apps with the desired interface

Original Source:https://medium.com/@semaphoresoftware/getting-started-with-asp-net-5-cross-platform-a7ffd400a873