Additional Information About ASP.Net Helios

Introduction

The new ASP.NET project named Helios was released last week. I've already described it in Introduction of ASP.NET Helios. I am providing an extra description that is also useful in the development.

Performance

In terms of web development performance, every developer thinks in terms of requests per second throughput. The real-time web application performs non-trivial request processing. There are many types of processing associated with it, like attaching files and accessing databases, with the use of this you'll assume that the performance must be very high. In past years the runtime of ASP.NET is very good when compared with the other frameworks or hosts.

Throughput is just one aspect of the performance. There are various resources using the web server and that sends the requests and each request consumes some portion of these share's resources and the server must be mindful of how resources are allocated to each request. If the concurrent requests are calculated per machine then how does one go about scaling the application up? The simple solution is to provide an extra hardware to the problem: built out of a web farm. 

Helios runtime without OWIN

In this section we use the Helios runtime assembly named Microsoft.AspNet.Loader.IIS.dll that is a standalone assembly and it does not have the direct integration with the OWIN pipeline. The application uses the APIs exposed by the Helios rather then using the OWIN extensibility points by the Microsoft.Owin.Host.IIS.

You could use his Helios APIs directly using the following procedure.

Step 1: Open Visual Studio 2013 and click on "New Project".

Step 2: Select "ASP.NET Web Application" and enter the name for the application.

Creating ASP.NET Web Application

Step 3: Choose the Empty Project Template to create the application.

Empty Project Template in VS 2013

Visual Studio automatically creates the application with the empty project template and as a default some files and references are added automatically.

Installing AspNet.Loader

Now in this section we add this assembly to the application using the following procedure.

Step 1: In the Solution Explorer, right-click on "References" then click on "Manage NuGet Packages".

Adding Manage NuGet Package

Step 2: Add the Microsoft.AspNet.Loader.IIS package as in the following.

Microsoft AspNet Loader in NuGet

Step 3: Add a class named IisLoader and replace the code with the code below:

using IISLoaderWebApp;
using Microsoft.AspNet.Loader.IIS;
using System;
using System.Threading.Tasks;
using System.Web;
using System.Text;
using System.Globalization;
[assembly: HttpApplication(typeof(IisLoaderApp))]
namespace IISLoaderWebApp
{
    internal static class ResponseExtensions
    {
        public static Task WriteAsync(this IHttpResponse response, string format, params object[] args)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(String.Format(CultureInfo.CurrentCulture, format, args) + Environment.NewLine);
            return response.WriteEntityBodyAsync(bytes, 0, bytes.Length);
        }
    }
    public class IisLoaderApp : HttpApplicationBase
    {
        public override async Task ProcessRequestAsync(IHttpContext HttpContext)
        {
            HttpContext.Response.StatusCode = 200;
            HttpContext.Response.StatusDescription = "Checked";
            HttpContext.Response.Headers["Content-Header"] = new[] { "text/plain" };
            await HttpContext.Response.WriteAsync("Current time {0}", DateTimeOffset.Now);
            var assembly = AppDomain.CurrentDomain.GetAssemblies();
            await HttpContext.Response.WriteAsync("Current Assembly", assembly.Length);
            foreach (var item in assembly)
            {
                await HttpContext.Response.WriteAsync(item.GetName().ToString());
            }
        }
    }
}

Step 4: Run the project.

Assembly Information

That's it.

Summary

This article described how to work with the AspNet.Loader.IIS assembly in the Helios Project without using the OWIN Host. Thanks for reading.


Similar Articles