The Visualization of Simulated Load-Bearing Soil Particles Using HttpHandler of ASP . NET

The Mincrosoft.NET Framework library provides a rich set of components and services for applications, greatly increasing the efficiency of software development. As the HttpHandler features no control parsing, it does not need to go through complicated page processing. Thus, the efficiency is significantly improved. It is especially suitable for the case where the server does not need to return HTML results to the client. This article demonstrates a simple application where HttpHandler and Ajax are combined to transfer large image data to the browser page and keep the display smooth, which proves their efficacy.


Introduction
In the simulation of soil particle distribution, the picture will be "flashing" constantly due to the application of webform, and the simulated graph cannot be clearly and smoothly displayed.In this scenario where the execution efficiency is highly emphasized and a large number of images are returned to the client, using webform is not competent.Instead, we could use another web component pro- IIS specifies that the request for the ASP.NET page, whose extension is .aspx,will be handled by aspnet_isapi.dll(for generic handlers, the request with the extension .ashx is also handled by aspnet_isapi.dll).When the worker process (w3wp.exe)loads aspnet_isapi.dll,it will create an HttpRuntime class, which is the entry for the application, and reacts to the request through the ProcessRequest method.Once the ProcessRequest method is called, an instance of the HttpContext is generated, followed by the HttpRuntime loads an HttpApplication object via the HttpApplicationFactory class.Multiple HttpModules are configured in HttpApplication.These HttpModules preprocess the request and then reach the HttpHandler.
All requests go through the HttpModule to the corresponding HttpHandler, and the HttpHandler starts processing the request.At this point, the ASP.NET page life cycle begins.At the end of the processing, results were further modified and returned by HttpHandler to HTTP.SYS.HTTP.SYS stores it in the buffer and forwards the result back to the requesting browser.Eventually, we get the content of the server response.The process flow is illustrated in Figure 1.

The ASP.NET Page Life Cycle
The definition of the ASP.NET page is as follows: The life cycle of a general ASP.Net page goes through the following stages: 1) The initialization of the page framework.This step raises the Init event for this page.
2) Loading the server control onto the Page object.
3) Handling the Postback event defined by the control in this page.
4) Generating corresponding HTML codes and render the Page object.
5) The page is unloaded from memory, triggering the Unload event.
At this point, the browser receives the HTML code of the entire page returned by the server and forwards it to the user.When the page is loading, the events executed from the Page class are summarized in

The HttpHandler
The HttpHandler is the fundamental core of the ASP.NETAs one of the .NET Web components.It is a class that contains the IHttpHandler special interface.
Any class that contains this interface can be used as a target program for the external request.
Generally, the HttpHandler could match classes in terms of most tasks.The workflow is as follows: a HttpHandler will obtain the client's request submitted to the server, accessing the server's file system and database, and form a non-HTML response content which will be returned to the client after the processing is completed.The definition of a HttpHandler is illustrated as follows:

F. Hu Journal of Computer and Communications
Several explanations are presented here for better comprehension: Property IsReusable: Acquiring a value indicating whether another request can use an IHttphandler instance.
Method ProcessRequest: Processing request using this method.
Class HttpContext provides access to the internal Request, Response, and Server properties of the request.

Asynchronous Javascript and XML
As stated before, when any part of the web page needs updating, the entire page will be automatically overloaded.Ajax (Asynchronous JavaScript and XML) enables asynchronous updates of web pages by performing small amounts of data exchange with the server backstage.This feature allows users to update the local content of a web page without reloading the entire web page.The core of Ajax technology is the XMLHttpRequest object, which offers a way to communicate with the server even after the page is loaded.Some functions include: 1) Updating the page without reloading the page; 2) Requesting data from the server after the page has been loaded; 3) Receiving data from the server after the page has been loaded; 4) Sending data to the server backstage.Some further properties are introduced as follows.
1) The major properties of the XMLHttpRequest object are explained as follows: readyState: state description which displays the state of the XMLHttpRequest.Its value changes from 0 to 4 and corresponds to different states: 0: Request not initialized 1: Server connection is established 2: Request has been received 3: Request is in processing 4: The request has been completed and the response is ready.The data can be retrieved via the corresponding attribute of the XMLHttpRequest object.
Status: Status attribute contributes to returning the server status code.When it equals 200, it represents the situation that the server has successfully accepted the client request.
Event handle on ready state change: The event handle on ready state change will be activated when the state of the XMLHttpRequest object changes.Its value is the name of this function.
responseText: Returns a response as a string.
The methods provided by the XMLHttpRequest object: Open(method, url, async): method corresponds to request type, which is POST or GET; url corresponds to the location of the file on the server; async corresponds to true (asynchronous) or false (synchronous).
Send(): Send the request to the server.
2) The basic working flow of AJAX is shown in Figure 2.

Application
In the discrete element modelling, which is a kind of numerical simulation especially suitable for soil mechanics research, it simulates soil as particle assemblage and the soil is assumed to be composed of quantities of small particles.In order to conduct more comprehensive qualitative and quantitative analysis, it is often necessary to smoothly display the information such as the motion trajectory, force chain and velocity of the soil particles during the loading process.This application works as follows.At the application server back end, based on the calculated response of the sample data under different conditions and under different stress states, we continuously generate a large number of soil sample particle distribution maps and present them on the browser front end.This application needs to continuously obtain the particle distribution map from the server, display it in the browser, and present various types of simulated motion trajectories.The front end adopts Ajax asynchronous request to avoid the "flashing" of the picture due to the refresh of the whole page when the picture is displayed on the screen; the back end is processing efficiently drawing upon the general processing program.Together, the combination of these two parts realizes the continuous and smooth illustration of the graphic.
ASP.NET is a worldwide prevalent programming framework based on the Microsoft's next-generation.Net platform, utilizes the Common Language Runtime to provide users with powerful enterprise-class Web application services at the server backend.During the Web application development based on ASP.NET, a large number of server controls and services provided by ASP.NET Framework enable us with the convenience as well as the efficiency due to the characteristics of Web applications.

Figure 1 .
Figure 1.The IIS workflow of processing requests.

Figure 2 .
Figure 2. The basic working flow of AJAX.3)JSON (JavaScript Object Notation) JSON is a syntax for storing and exchanging text information.It is a lightweight text data-interchange format that is easy for people to read and write, which is also true for machine parsing and generation.It is smaller and faster than XML and uses the built-in JavaScript eval() method for parsing.AJAX technology makes each request faster and returns only the data it needs for each request.Overall speaking, for AJAX applications, JSON is faster and easier than XML[5] [6].

Page Request and Response in ASP.NET 2.1. IIS Processing Suppose
NET: the HttpHandler, which is significantly time-saving and could transfer relatively larger data.And it should be noted that in this article, the application programming and operation are both carried out under IIS 6.0. the browser sends a request to the web server to retrieve the contents of an ASP.NET site.When the request arrives at the web server, it is received by the HTTP.SYS.HTTP.SYS processes the information about this HTTP request and distributes it to the appropriate application pool based on its URL.Once the ap- F. Hu DOI: 10.4236/jcc.2019.74001 2 Journal of Computer and Communications vided by ASP.2.

Table 1 .
The method execution sequence when the page is loaded.