Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->编程语言 ->ASP ->正文

微软提供的功能强大的ASP-HTML转换工具.它将常用的ASP脚本转换为HTML从而减轻服务器的负担

来源:Linuxdby.com 作者:Webmaster 时间:2007-06-01 点击: [收藏] [投稿]

browser technology such as the Microsoft WebBrowser control. While I'll use Visual Basic?here, you can
also use C++. As a good starting point in C++, you can try the MFCIE or ATLBrowser samples, both of which
come with the latest Platform SDK. In Figure 1 you can see the layout of the browser. For illustration,
I've divided the client area into three blocks: one for the actual HTML rendering, one for the original
ASP text, and one for the expanded HTML text. Figure 2 shows the code for the browser.

Figure 1 The Custom ASP Browser  

During the form's initialization, a new CAspParser object is created and set to work properly. Once you've
clicked the Go button, the browser detects whether you're calling the ASP page locally or over HTTP, and
acts accordingly. All the logic is hidden in the CAspParser class, which exposes three public functions:
Initialize, SetScriptControl, and ParseTextToFile. Initialize makes sure the scripting environment is
properly initialized and ready to work. Through SetScriptControl, the class receives the working instance
of the script environment (more on this later). ParseTextToFile parses the content of the given ASP file
and creates an output stream. Basically, the parser reads the whole content of the ASP file into memory
and then walks through it. It locates any occurrence of "<%", then copies the text that precedes "<%" to
the output buffer, and starts a new search for the closing tag, "%>". The command text is extracted and
processed separately. Any output is then appended to the response buffer.
The script code in the body of an ASP page may contain references to the intrinsic objects that form the
ASP object model. These well-known objects are listed in Figure 3. IIS is responsible for making these
objects—plus two more: ASPError and ObjectContext—available in the script's namespace when the parser is
about to process the content of the various code blocks. To obtain an ASP parser that works outside the
Web server, you should provide a replacement for these objects, which means building a client-side ASP
object model.



A Client-side ASP Object Model
One of the problems with Web applications is the inability to maintain state when working over HTTP. State
is the ability to associate variables and objects with a particular user. A tool to store individual
settings and resources can solve the problem. This is what the Session and Application objects provide,
albeit at different levels. But you don't always need to implement this feature in a client-side ASP
object model. In fact, a local ASP page is normally accessed by one user at a time and state management is
a far less important issue.
From the perspective of an offline ASP viewer, the key ASP objects are Response and Request because they
provide the basic functionality that make a page interact with the rest of the world. Whether you need to
implement all or a part of the standard methods and properties depends on your particular project.
Although ASP is tightly integrated with IIS and Microsoft Transaction Services (MTS), and COM+
environments, this doesn't mean that you cannot use a unified, yet ASP-based approach for the concurrent
development of products that deliver content through different media (like the Web and CDs). Offline pages
consumed without the intervention of the Web server are normally much simpler and don't need all the
features of an online Web application. Based on my personal experience, I suggest you implement a minimal
set of features (similar to those I discuss here) and then extend the set when your pages need to support
extra ASP features.
I deployed the first version of my project with only Response and Request objects. In particular, I only
implemented the Write method of the Response object, and just for the HTML content type. Request only
exposed the QueryString collection. In a second step, I added support for Response.End and the Request's
Form and ServerVariables collections. Later, I also added some special features such as new environment
variables and new offline-only objects, including Scripting.FileSystemObject.
The key questions concern how you simulate the Response or Request object and how you run all the script
code that an ASP file contains. To execute script code, you can either take advantage of the Microsoft
Script Control—a downloadable component (see http://msdn.microsoft.com/scripting/), or use the raw
Windows Script COM interfaces. For a primer, look at the Extreme C++ column in the August 1997 issue of
Microsoft Internet Developer. Since I'm developing an application in Visual Basic, using the Script
Control is the natural choice.


The Script Control
ScriptControl is an ActiveX?control without a user interface that wraps all the Windows Script interfaces
needed for dialog with a script language parser. It has a Language property through which you select a

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:StoredProcedure在企业网站开发中的应用(1)   下一篇:动态网页技术--CGI:ASP:JSP:PHP(1)

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号