MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

Getting Started with ASP.Net 5 Cross Platform

Published on 04 June 15
0
2
Getting Started with ASP.Net 5 Cross Platform - Image 1

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;

Related Posts:
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top