分享
 
 
 

Internet Information Server (IIS) Objects

王朝asp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

Internet Information Server (IIS) Objects

IIS supplies many objects that can be used by hosting platforms such as ASP

and ASP.NET. These objects aren't new in ASP.NET梩hey're the same objects

(with a few new properties) that you might have used in an ASP application.

You can use these objects to return information about your application and

your IIS server. ASP.NET makes all these objects available to you from the

code in your Web Form's code-behind file.

The Response Object

The Response object allows you to place information into the HTML stream

prior to sending a complete HTML page back to the client. For example, you

could include code such as this to insert text directly into the rendered

output:

Response.Write("An invalid password was entered")

The Request Object

The Request object allows you to receive information from the user.

Requests can be input fields on an HTML page or values passed on the URL.

The following code retrieves the value from a text box on the requesting

page:

strLastName = Request("txtLastName").ToString()

The Request object can also retrieve information from a URL. For example,

given the URL

http://www.yoursite.com/YourPage.aspx?Keyname=John

as entered from the browser, you could retrieve the Keyname parameter using

code like this:

Request.QueryString("KeyName")

The Session Object

IIS creates a Session object globally, once for each user's session. Using

this object, you can retrieve and set properties such as Session.TimeOut

and Session.SessionID. The TimeOut property indicates how long to wait for

a user to respond to a page before IIS kills the session. The SessionID

property is a unique long integer value that corresponds to this specific

session. The Session object also provides a dictionary-type collection of

name/value pairs. You can also add and retrieve your own variables within

this object. The following code takes a value from the Request object and

stores it as a Session variable for later reuse:

Session("LoginID") = Request("txtLoginID")

If you run this same line of code again, it will replace the contents in

the LoginID session variable with the updated contents of the txtLoginID

value. The Session object and all its contents are destroyed when a user

leaves a site or when the session times out.

TIP

You may have discovered that using Session and Application objects梐nd

their associated dictionaries of values梬asn't a good idea in ASP because

of scalability issues and because of the need to save data as cookies on

the user's computer. These issues have been handled in ASP.NET, and you'll

learn more about state management in Chapter 23.

The Application Object

IIS supplies another global object, Application. IIS creates this object

the first time a user comes to a Web site. You might use the Application

object to store a database connection string. Because the connection

information doesn't need to change from user to user, the Application

object is a perfect place to store this type of information. For example,

the following code stores a connection string so that it can be accessed at

any time within your site's processing:

Application("ConnectString") = _

"Provider=sqloledb;Initial Catalog=Employees;" & _

"Data Source=DataServer"

The Server Object

The Server object has some properties that relate to information in the IIS

server. You might call the MapPath method if you need to return a hyperlink

to a file on the server in a virtual directory. Here's an example:

strPath = Server.MapPath("EmpMaint")

The preceding code might return the following for a specific Web site:

d:\inetpub\wwwroot\EmpWeb\EmpMaint

The global.asax File

The global.asax file is similar to the global.asa file in ASP, although

there are more events available in ASP.NET. Also, just as ASP.NET compiles

the code in every page regardless of which language you use to create the

code-behind file (as opposed to interpreting the code, as in ASP), the code

in global.asax is fully compiled as well. ASP.NET allows you to handle a

sequence of site-wide events using code in your global.asax file. Table 6.5

lists the event procedures available to you within the global.asax file.

Table 6.5. Event Procedures Available Within global.asax Event Procedure

Description

Application_Start Raised when the first user hits your Web site.

Application_End Raised when the last user in the site's session times

out.

Application_Error Raised when an unhandled error occurs in the

application.

Session_Start Raised when any new user hits your Web site.

Session_End Raised when a user's session times out or ends.

Application_AcquireRequestState Raised when ASP.NET acquires the current

state (for example, session state) associated with the current request.

Application_AuthenticateRequest Raised when a security module establishes

the identity of the user.

Application_AuthorizeRequest Raised when a security module verifies user

authorization.

Application_BeginRequest Raised when ASP.NET starts to process the

request, before other per-request events.

Application_Disposed Raised when ASP.NET completes the chain of execution

when responding to a request.

Application_EndRequest Raised as the last event during the processing of

the request, after other prerequest events.

Application_PostRequestHandlerExecute Raised right after the ASP.NET

handler (such as a page or XML Web Service) finishes execution.

Application_PreRequestHandlerExecute Raised just before ASP.NET begins

executing a handler (such as a page or XML Web Service).

Application_PreSendRequestContent Raised just before ASP.NET sends content

to the client.

Application_PreSendRequestHeaders Raised just before ASP.NET sends HTTP

headers to the client.

Application_ReleaseRequestState Raised after ASP.NET finishes executing

all request handlers. This event causes state modules to save the current

state data.

Application_ResolveRequestCache Raised after ASP.NET completes an

authorization event to let the caching modules serve requests from the

cache, bypassing execution of the handler (the page or Web Service, for

example).

Application_UpdateRequestCache Raised after ASP.NET finishes executing a

handler in order to let caching modules store responses that will be used

to serve subsequent requests from the cache.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有