25 November 2004

ASP.NET page life cycle

Paul Wilson's article Page Events: Order and PostBack
and Dino Esposito's
The ASP.NET Page Object Model are good reminders for questions like 'When does this (server-side) Textbox validation happen?' and 'Where do I assign the regular expression for validator?'

24 November 2004

Yet another Microsoft Exam

Now I am a MCAD! This time I am taking on '070-229 Designing and Implementing Databases with Microsoft SQL Server 2000 Enterprise Edition' with the help from Professional SQL Server 2000 Programming, by R, Viera. Persnally, I don't like the book. The concepts and practices in each chapter is very loose. It is at lack of structural way of presenting idea. And it will be better if Viera is not using overly verbal language and side-tracking jokes. It will be more painless to read if it can be more concise. I found using Sql Server Book On Line offers great help.

Anyway it covers everything and it is a seriously huge book. My day bag is much lighter now.

19 November 2004

ADO.NET and SQL Server security, performance Recommendations

The typical application scenario is an internet web application located in DMZ then submits data via ADO.NET, either in-process or though middle tier.

1. Use windows authentication.
1) The web server should not be in the trusted domain. Create a local NT user account ‘Fred’ with least privileges. This account will be used as the IIS anonymous access account for the web application.
2) Enable IIS anonymous access for the web application.
3) On the Sql Server, mirror the NT account ‘Fred’ created above. Set Sql Server security login mode to be ‘Windows Only’.
4) Create a SQL Server Login for ‘Fred’. Grant ‘Fred’ to ‘Public’, ‘Deny Data Reader’ and ‘Deny Data Writer’ access.
5) Allow application access data via Store Procedures only. Grant ‘Fred’ to all user- defined store procedures exec rights.

2.When you specify a server in an ADO.NET connection string, always use IP address instead of the server's DNS name to cut the overhead on DNS resolution.

3.Specify 'Application Name' in the connection string. It makes SQL Profiler can pick up the connections quite handy, or just for trouble-shooting.

4.Do not use SQL Server application roles, it turns off connection pooling.

5.When possible, use the ExecuteNonQuery method with SQLCommand objects, as this is the most efficient way to execute queries from ADO.NET. Use output parameters with SQLCommand objects if you need to retrieve just a few values, or a single data row, instead of using more expensive techniques, such as a SQLDataAdapter, a SQLDataReader, or a strongly typed DataSet.

6.Avoid using Transact-SQL cursor at all possible, try use correlated sub-query or temporary table instead.