Rickie Lee's blog

Welcome to my blog. I'm mainly involved in .Net platform and corresponding technologies. Thanks.

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  383 随笔 :: 3 文章 :: 1240 评论 :: 98 Trackbacks

2008年4月29日 #

CodeProject: ASP.NET Page Life Cycle


This article describes the life cycle of the page from the moment the URL is hit from the web browser till the HTML code is generated and sent to the web browser. Let us start by looking at some keywords that are involved in the life cycle of the page.
........

Events in the life cycle of page

PreInit: All the Pre and Post events are introduced as part of .NET Framework 2.0. As the name suggests this event is fired before the Init method is fired. Most common functionalities implemented in this method include

a. Check the IsPostBack property
b. Set the master page dynamically
c. Set the theme property of the page dynamically
d. Read or Set the profile property values.
e. Re-create the dynamic controls

Init: This event is raised after all controls in the page are initialized and any skin settings have been applied. This event is used to read or initialize control properties. It can be used to register events for some controls for which the events are not specified in the aspx page.
Ex: OnClick event of the Button can be registered in the Init rather than specifying in the OnClick property of the Button in the aspx page.

InitComplete: Use this event for processing tasks that require all initialization be complete.

PreLoad: Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.

Load: The Page calls the OnLoad event method on the Page, then recursively does the same for each child control, which does the same for each of its child controls until the page and all controls are loaded. Use the OnLoad event method to set properties in controls and establish database connections.

Control events: Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.

LoadComplete: Use this event for tasks that require that all other controls on the page be loaded.

PreRender: This is the last event raised before the HTML code is generated for the page. The PreRender event also occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.

SaveStateComplete: Before this event occurs, ViewState has been saved for the page and for all controls. Any changes to the page or controls at this point will be ignored.
Use this event perform tasks that require view state to be saved, but that do not make any changes to controls.

Render: This is the stage where the HTML code for the page is rendered. The Page object calls the Render method of each control at this stage. All ASP.NET Web server controls have a Render method that writes out the control's markup that is sent to the browser.

UnLoad: This event occurs for each control and then for the page. In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.
For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.

Source URL:
http://www.codeproject.com/KB/aspnet/PageLifeCycle.aspx


posted @ 2008-04-29 10:32 Rickie 阅读(573) | 评论 (0)编辑

2008年4月25日 #

为 SQL Server 启用 AWE 内存

下面的示例显示如何激活 AWE 以及如何为 min server memory 配置 1 GB 的限制,为 max server memory 配置 6 GB 的限制。

首先,配置 AWE:
-- turn on advance configuration
sp_configure 'show advanced options', 1
reconfigure with override
go

-- enable extended memory
sp_configure 'awe enabled', 1
reconfigure with override
go

然后,配置内存:
-- enable RAM for SQL
sp_configure 'min server memory', 1024
reconfigure with override
go

sp_configure 'max server memory', 6144
reconfigure with override
go

Reference:
http://technet.microsoft.com/zh-cn/library/ms190673.aspx



posted @ 2008-04-25 16:15 Rickie 阅读(354) | 评论 (0)编辑

2008年3月20日 #

PAGEIOLATCH_SH: Occurs when a task is waiting on a latch for a buffer that is in an I/O request. The latch request is in Shared mode. PAGEIOLATCH_SH waits is very brief as they are only held on a page during IO operations.

You can also identify I/O bottlenecks by examining the latch waits. These latch waits account for the physical I/O waits when a page is accessed for reading or writing and the page is not available in the buffer pool. When the page is not found in the buffer pool, an asynchronous I/O is posted and then the status of the I/O is checked. If I/O has already completed, the worker proceeds normally. Otherwise, it waits on PAGEIOLATCH_EX or PAGEIOLATCH_SH, depending upon the type of request. The following DMV query can be used to find I/O latch wait statistics.

Select  wait_type, 
        waiting_tasks_count, 
        wait_time_ms
from    sys.dm_os_wait_stats  
where    wait_type like 'PAGEIOLATCH%'  
order by wait_type

More detail information on performance probblems in SQL Server 2005, please navigate to the following article.

Troubleshooting Performance Problems in SQL Server 2005
http://www.microsoft.com/technet/prodtechnol/sql/2005/tsprfprb.mspx



posted @ 2008-03-20 11:46 Rickie 阅读(578) | 评论 (0)编辑

2008年3月18日 #

Wait type - CXPACKET 

It means SQL Query is involved in parallel query execution. This waittype indicates that the SPID is waiting on a parallel process to complete or start.

CXPACKET: Occurs when trying to synchronize the query processor exchange iterator. You may consider lowering the degree of parallelism if contention on this wait type becomes a problem.

******
How to configure cost threshold for parallelism Option

Use the cost threshold for parallelism option to specify the threshold at which Microsoft SQL Server creates and runs parallel plans for queries. SQL Server creates and runs a parallel plan for a query only when the estimated cost to run a serial plan for the same query is higher than the value set in cost threshold for parallelism. The cost refers to an estimated elapsed time in seconds required to run the serial plan on a specific hardware configuration. Only set cost threshold for parallelism on symmetric multiprocessors.

Longer queries usually benefit from parallel plans; the performance advantage negates the additional time required to initialize, synchronize, and terminate parallel plans. The cost threshold for parallelism option is actively used when a mix of short and longer queries is run. The short queries run serial plans, whereas the longer queries use parallel plans. The value of cost threshold for parallelism determines which queries are considered short, and they should therefore be run using serial plans.

In certain cases, a parallel plan may be chosen even though the query's cost plan is less than the current cost threshold for parallelism value. This can happen because the decision to use a parallel or serial plan is based on a cost estimate provided before the full optimization is complete.

The cost threshold for parallelism option can be set to any value from 0 through 32767. The default value is 5.

SQL Server ignores the cost threshold for parallelism value under the following conditions:

  • Your computer has only one processor.
  • Only a single CPU is available to SQL Server because of the affinity mask configuration option.
  • The max degree of parallelism option is set to 1.

The cost threshold for parallelism option is an advanced option. If you are using the sp_configure system stored procedure to change the setting, you can change cost threshold for parallelism only when show advanced options is set to 1. The setting takes effect immediately (without a server restart).

sp_configure 'show advanced options', 1;

GO

reconfigure;

GO

sp_configure 'cost threshold for parallelism', 10;

GO

reconfigure;

GO

posted @ 2008-03-18 18:40 Rickie 阅读(666) | 评论 (0)编辑

2008年3月12日 #

Introduction

This topic describes the elements in the Web.config file that support Microsoft ASP.NET AJAX. It also describes how to incorporate those elements into the Web.config file for an existing ASP.NET application.

Please access the following URL to get more detail.
http://asp.net/AJAX/Documentation/Live/ConfiguringASPNETAJAX.aspx


posted @ 2008-03-12 13:12 Rickie 阅读(219) | 评论 (0)编辑

If you have installed TFS and have not configured your SMTP server, you may do so as follows:
  • On the Team Foundation Server box, navigate to: C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\Web Services\Services. If you have it on a drive other than C:\, besure to change this.
  • Open the web.config file
  • Modify the following keys in Red

  <appSettings>
    <add key="ConnectionString" value="Application Name=TeamFoundation;Persist Security Info=False;Initial Catalog=TfsIntegration;Data Source=TFSServerName;Integrated Security=SSPI"/> 
    <add key="eventingEnabled" value="true" />
    <add key="DetailedExceptions" value="true" />
    <add key="emailNotificationFromAddress" value="Senders Email Address" />
    <add key="smtpServer" value="Your SMTP Server Name" />
  </appSettings>

By default, the smtpServer key value will be the name of your Team Foundation Server. be sure you enter a valid SMTP server name and a valid email address for the sender.

  •  Fire up VS2005 and set up a Project Alert if you have not done so already.
  • Cause a change that should fire of an email and check you email to see the results.

============

Using HTML Administration to Configure E-Mail Settings for Windows SharePoint Services

You use the Configure Default E-mail Server Settings page to specify e-mail settings for your server.

Specify e-mail settings for a server or server farm

1.

On the SharePoint Central Administration page, under Server Configuration, click Configure default e-mail server settings.

2.

In the Outbound SMTP server box, type the name of the SMTP mail server to use for sending messages.

3.

In the From e-mail address box, type the e-mail address to send e-mail messages from. This address appears in the From box of any e-mail messages from the server. No e-mail messages are sent to this address, so you can use an unmonitored e-mail address if you want.

4.

In the Reply-to e-mail address box, type the e-mail address that users can reply to. If a user replies to an e-mail message from the server, it will be sent to this address. You should use an address that is monitored for the reply-to address.

5.

In the Character set box, select the character set to use.

6.

Click OK.

posted @ 2008-03-12 08:56 Rickie 阅读(166) | 评论 (0)编辑

2008年2月22日 #

日志的逻辑文件名是DBNAME_LOG,数据库DBNAME:  
USE   DBNAME  
BACKUP LOG DBNAME WITH NO_LOG       --截断事务日志  
GO

OPTION 1:
DBCC SHRINKFILE(DBNAME_LOG,10)      --收缩事务日志  
GO  

OPTION 2:
企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了

如果想以后不让它增长
企业管理器--服务器--右键数据库--属性--事务日志--将文件增长限制为xM(x是你允许的最大数据文件大小)
--SQL语句的设置方式:
alter database 数据库名 modify file(name=逻辑文件名,maxsize=20)

posted @ 2008-02-22 10:12 Rickie 阅读(333) | 评论 (0)编辑

2008年2月20日 #

A couple of strange warnings in the Security event log always occur when then transaction fails:
Log 1:
Event Type: Failure Audit
Event Source: Security
Event Category: Account Logon
Event ID: 680
Date:  2008-2-20
Time:  9:43:10
User:  NT AUTHORITY\SYSTEM
Computer: ****
Description:
Logon attempt by: MICROSOFT_AUTHENTICATION_PACKAGE_V1_0
 Logon account: ****$
 Source Workstation: ****
 Error Code: 0xC0000064

Log 2:
Event Type: Failure Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 529
Date:  2008-2-20
Time:  9:43:10
User:  NT AUTHORITY\SYSTEM
Computer: ****
Description:
Logon Failure:
  Reason:  Unknown user name or bad password
  User Name: ****$
  Domain:  WORKGROUP
  Logon Type: 3
  Logon Process: NtLmSsp
  Authentication Package: NTLM
  Workstation Name: ****
  Caller User Name: -
  Caller Domain: -
  Caller Logon ID: -
  Caller Process ID: -
  Transited Services: -
  Source Network Address: IP ADDRESS
  Source Port: 2044

=========================
If the two machines are in different domains, then this is likely what is happening:

When DTC negotiates a connection with another transaction manager, it will always attempt a secure connection first. If this fails, and security is disabled for DTC, then it will attempt a connection without passing any credentials.

In the above scenario the two servers enlisting in a transaction were in seperate domains. When DTC would try to connect with DTC on the remote server, it did so in a secure manner and passed the machine account. This account did not exist in the domain of the remote server, which resulted in the failure audits in the security logs with an HRESULT of 0xC00000064. This error code means no such user exists. DTC then attempted an unauthenticated connection that was
successful and allowed the application to work.

A Netmon trace should show you this behavior.

============================
The above content is from the following POST.
http://www.winserverkb.com/Uwe/Forum.aspx/exchange-admin/57957/Security-Failure-for-an-administrative-account




posted @ 2008-02-20 11:01 Rickie 阅读(265) | 评论 (0)编辑

2008年2月2日 #

The following SQL statement is used to reconfigure the SQL SERVER advanced settings, such as max text repl size.

sp_configure 'max text repl size', 2147483647
GO
RECONFIGURE;

You can also configure this kind of advanced settings via the UI property windows  form. Right click on SQL server instance name, select "property" menu item, then click on "Advanced" tab in the "Server properties" windows form.


posted @ 2008-02-02 13:58 Rickie 阅读(198) | 评论 (0)编辑

2008年1月31日 #

ChannelFactory

 

 

The following example illustrates how to use the ChannelFactory class to create a channel on the client to send messages with the service endpoint.

 

In order to create and manage channels, you need to import the System.ServiceModel.Channels namespace.

 

Let’s take a look at the following code snippet.

 

ChannelFactory<TCP.IServiceClass> factory = new

ChannelFactory<TCP.IServiceClass>(“WSHttpBinding_IServiceClass”);

TCP.IServiceClass channel = factory.CreateChannel();

 

The above code is the construction and management of the channel. The first line initializes a new instance of the ChannelFactory class. This is necessary to create the channel. In the constructor of this class, you pass the name of the endpoint in which this channel will communicate. The second line creates the channel (Service Contract) which is used to communicate with the client.

 

Next is to call the exposed method, then release ChannelFacotry instance.

result = channel.AddNumbers(val1, val2);

factory.Close();

 

 

posted @ 2008-01-31 18:33 Rickie 阅读(217) | 评论 (0)编辑