Friday, March 18, 2011

ATL Server and asp.net

The Web server's task is to accept an incoming HTTP request, and return to the calling party information (whether or not the caller is a person, or a Web service of the machines).

Windows contains a processing request mature structures — IIS and its related extensions. However, IIS is scratch design is very tedious and error prone. Manage HTTP request a better approach is to use is located at the top of the IIS a framework to manage. This month I will compare two ways to create WindowsWeb application's primary technology: asp.net with ATLServer. Each frame has some specific advantages and disadvantages. In this section, I will focus on how to use asp.net management Web-based UI. Next time I will focus on how to use the framework to build Web services and other features. Asp.net? asp.net is to handle HTTP requests and design class libraries. In addition to the class library, asp.net also contains several management requests IIS components. These components include the named ASPNET_ISAPI.DLL ISAPIDLL and known as the ASPNET_WP.EXE worker process. Asp.net also in IIS is installed on the new map, ASPX, ASCX, ASHX and ASMX file redirects the request to ASPNET_ISAPI.DLL. At this point, the request is redirected to the ASPNET_ISAPI.DLL ASPNET_WP.EXE, in the process, load the required asp.net class to provide the service requested. To name the HttpContext of the managed class as the Center, there is a very convenient asp.net's object model. If you wrote a standard ISAPIDLL, be sure to understand the EXTENSION_CONTROL_BLOCK and passed to the HttpExtensionProc ISAPIDLL. Management request, this structure ISAPIDLL to obtain such as environmental ID, query strings, as well as reading and writing client-side functions, and so on. Asp.net will all of this information is packaged in the HttpContext class. Asp.net also includes management of Web-based UI (through the System.Web.UI.Page class) and the management Web service (through the System.Web.Services.WebService [WebMethod] classes and attributes) of the basic class structure. Asp.net is object oriented. Each pass through asp.net application requests are called the IHttpHandler class, the class can implement interfaces. This will bring up a highly scalable architecture. You can choose to use asp.net page architecture or the Web services architecture, or you can also write the processing logic from scratch. Figure 1 shows the path taken by asp.net requests. ASP.NETUI-processing architecture to web.ui.page class (the ASPX file) as the Center. ASPX files can include neat HTML code and server-side control. When asp.net encounters a server-side controls (via the "runat = server" property), it will instantiate a class that represents the control (for example, a Button and ListBox controls). In essence, asp.net page as these server-side control tree to handle (the text on the page and the tag is packaged as LiteralControl class) — other are server-side control. When asked to render the page itself, the page just loop through the control tree, "tell" the tree of each node render themselves. ATLServer operates somewhat differently. ATLServer? ATLServer is used to create ISAPIDLL c++ template library. When you first create the IIS, the developer must from scratch or from MFC ISAPIDLL class as a starting point to write an ISAPI extension. Use the original c++ or MFC code generation ISAPIDLL need manual extension code. For example, there is no MFCISAPI provides developers with form-based architecture. Any client end of the HTML tag must be artificial to sent. ATLServer will be based on the form and run-time speed and flexibility of the C + +. Construction with ATLServer Web site consists of three basic components: a server response file (SRF), application DLLs and prerequisite of the ISAPI extension. SRF is ATLServer installed in IIS in a new file. SRF maps will point to the application's IIS ISAPIDLL, which in turn will handle points to one or more application DLLs. SRF includes a special new markup syntax, which is essentially in the application DLL entry point is called. Figure 2 shows the request based on ATLServer through system used by the path. ATLServer application consists of many DLL (ISAPI extension and application extension) and is called the SRF (mentioned earlier) HTML generated templates. This architecture has made it clear that the application and the separation of application logic. Web page that contains HTML and special tags to define the SRF. These tags called ATLServer application DLLs. Since most Web application's target platform is Windows, therefore ATLServer application built on ISAPIDLL. ATLServer project contains a rough requests can be processed in a single ISAPI extension DLL。 ATLServer application also contains used for a variety of precise request processing by one or more application DLLs. Processing requests for classes derived from CRequestHandlerT and also contains your own unique, used to handle the SRF tag in the code. The handler class that contains the request handler class and the request handler DLL to associate, and overrides the method and associate SRF tag dictionaries. In addition to the alternative dictionaries, CRequestHandlerT also contains access standard Web application element methods and member variables, for example, form variables, cookies, request stream, as well as the response stream. When the browser find .srfURL via HTTP, IIS know ISAPIDLL ATLServer application to open the site. ATLServer application then open the SRF, and loads the application DLL (if they haven't loaded). The application then the request is sent to the default request handler class that the SRF is parsed, in search of a special token markup. Each time the SRF tags appears in, the application calls the existence to a particular application DLL a handler class of alternative methods. The alternative method to dynamically generate the browser's output. Figure 2 shows a ATLServer application path of the request. ATLServer and asp.net although ATLServer and asp.net are ISAPI-based architecture, but they are processing requests in very different ways. To illustrate these differences, let's look at a sample application, the application collects personal name and his or her development preferences. I will explain how to develop user interface and how to use session state. In the next part of this column, I will examine some of the other features (such as caching and browser capabilities), as well as each frame on the Web service works. Figure 3 compares the two frameworks of some functionality. ASPX files and SR asp.net and ATLServer as ISAPI architecture introduces a new file name extension. Asp.net into file types are ASPX, ASMX, ASCX, ASHX, there are some other type. In the framework of asp.net file types each with a corresponding managed type. For ASPX files, this is the System.Web.UI.Page class. The Page class is responsible for rendering Web pages based on the UI. Figure 4 shows a simple ASPX file. With regard to the ASPX file it should be noted that the main issues are, at the top near the inherited instructions, and buttons, labels, and drop-down list labeled "runat = server" property. This mark indicates that the server-side controls in VisualStudio in code-behind file of the corresponding class. By contrast, the SRF includes most standard, the most common HTML tags. ATLServer no server-side component architecture. However, it introduces the concept of server response markers. These special tags with double braces ({{}}). When ATLServer request architecture experience a server response markers, it expects the application to find a corresponding DLLÖÐ handler function. Figure 5 shows a simple SRF, it displays the user interface and figure 4ASPX example of roughly the same as the user interface. This file need to be aware of the most important issues is by double braces enclose the special tags. For example, near the top of the SRF, you see the specify application default handler handler tag ({{handler ...}}). This tells ATLServer application loads a DLL, to find the function called in response to the tag. Other response markers pointed out that the application DLL entry point. "Intrinsic" object asp.net and ATLServer contains similar intrinsic request and response objects, and typical ASPÒ» Ñ ù. in asp.net, their HttpRequest and HttpResponse class used to represent. In ATLServer, they use the CHttpResponse and CHttpRequest class to represent. In each frame, their uses are basically the same. The request object encapsulates such as request parameters and URL, and other items. Response object contains the text output to the client. For example, in order to provide a requested based on asp.net output stream into the "HelloWorld", just call to Response.Write, as follows: protectedvoidHelloWorld () {Response.Write ("HelloWorld"); } To ATLServer application based client output "HelloWorld", use the CHttpResponse object, as follows: [tag_name (name = "Hello")] HTTP_CODEOnHello (void) {m_HttpResponse returnHTTP_SUCCESS; Pay attention to how to use} Figure 5 server response flags to call OnHello function. (This tag as follows: Hello. ) To manage the UI elements each frame uses a different method to manage the UI elements. As previously mentioned, asp.net UI support around server-side control model. Represents a code (the ASPX file) using the runat = "server" attribute declared on a Web page, the server-side elements. As long as the code-behind class soundClear the corresponding classes to programmatically access the control easily. For example, the code in Figure 4 illustrates several server-side control elements (for example, the submit button, the text element, and drop-down list). The code-behind page Button, TextBox and DropDownList class declared as members of the page so that you can program using these UI elements. In order to find the data in the TextBoxName element, only may need to access the Text property, as follows: Strings = this.textboxname.text; Asp.net there are server-side control to automatically track the view state. When a browser and from the access server, the UI elements (as, list boxes and radio buttons) will keep them in a consistent state. For example, the last time in the drop-down list box, select the item that is displayed. There is no need to write any special code to ensure that the control's behavior is correct. ATLServer no such control model. Only through server response token management UI. In order to populate the drop-down list, a sample with ATLServer

No comments:

Post a Comment