Wednesday, September 12, 2007
Visual Confirmation Code
System.Data
System.Drawing
System.IO
System.Text
System.Security.Cryptography
########################
###The Code Goes here
########################
Dim strVisualString As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack = True Then
GenerateVisualConfirmationCode()
End If
End Sub
Sub GenerateVisualConfirmationCode()
Dim str As String = Server.MapPath("../images/VisualConfirmation/test1.jpg")
Dim str2 As String = Server.MapPath("../images/VisualConfirmation/test3.jpg")
If System.IO.File.Exists(str2) Then
System.IO.File.Delete(str2)
End If
Dim b As New System.Drawing.Bitmap(str)
Dim f As New Font("Arial", 30)
Dim graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(b)
Dim width As Integer = CInt(graphics.MeasureString("ABCDEFGH", f).Width)
Dim height As Integer = CInt(graphics.MeasureString("ABCDEFGH", f).Height)
b = New Bitmap(b, New Size(200, 50))
graphics = System.Drawing.Graphics.FromImage(b)
'graphics.Clear(Color.DarkBlue)
graphics.Clear(Color.White)
strVisualString = RandomString(6)
graphics.DrawString(strVisualString, f, New SolidBrush(Color.Black), 0, 0)
graphics.Flush()
b.Save(str2, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Function RandomString(ByVal iLength As Integer) As String
Dim iZero, iNine, iA, iZ, iCount, iRandNum As Integer
Dim sRandomString As String
Dim rRandom As New Random(System.DateTime.Now.Millisecond)
iZero = Asc("0")
iNine = Asc("9")
iA = Asc("A")
iZ = Asc("Z")
sRandomString = ""
While (iCount < iLength)
iRandNum = rRandom.Next(iZero, iZ)
If ((iRandNum >= iZero) And (iRandNum <= iNine) Or (iRandNum >= iA) And (iRandNum <= iZ)) Then
sRandomString = sRandomString + Chr(iRandNum)
iCount = iCount + 1
End If
End While
RandomString = sRandomString
End Function
Thursday, June 21, 2007
Non ASCII Characters with MySQL
Storing Non ASCII Characters in Database
MySQL can store non ASCII characters in database in a number of encodings, MySQL call them character sets:
+----------+-----------------------------+
Charset Description
+----------+-----------------------------+
big5 Big5 Traditional Chinese
dec8 DEC West European
cp850 DOS West European
hp8 HP West European
koi8r KOI8-R Relcom Russian
latin1 ISO 8859-1 West European
latin2 ISO 8859-2 Central European
swe7 7bit Swedish
ascii US ASCII
ujis EUC-JP Japanese
sjis Shift-JIS Japanese
cp1251 Windows Cyrillic
hebrew ISO 8859-8 Hebrew
tis620 TIS620 Thai
euckr EUC-KR Korean
koi8u KOI8-U Ukrainian
gb2312 GB2312 Simplified Chinese
greek ISO 8859-7 Greek
cp1250 Windows Central European
gbk GBK Simplified Chinese
latin5 ISO 8859-9 Turkish
armscii8 ARMSCII-8 Armenian
utf8 UTF-8 Unicode
ucs2 UCS-2 Unicode
cp866 DOS Russian
keybcs2 DOS Kamenicky Czech-Slovak
macce Mac Central European
macroman Mac West European
cp852 DOS Central European
latin7 ISO 8859-13 Baltic
cp1256 Windows Arabic
cp1257 Windows Baltic
binary Binary pseudo charset
geostd8 GEOSTD8 Georgian
+----------+-----------------------------+
To store non ASCII characters in a database column, you need to define that column with
a specific character set. You can specify a character set at 3 levels: database, table, and column.
For example:
CREATE DATABASE db_name CHARACTER SET utf8
CREATE TABLE tbl_name (...) CHARACTER SET utf8
CREATE TABLE tbl_name (col_name CHAR(80) CHARACTER SET utf8, ...)
- If a character set is specified at the database level, it is applied to all CHAR, VARCHAR,
and TEXT columns of all tables in this database. - If a character set is specified at the table level, it is applied to all CHAR, VARCHAR,
and TEXT columns in this table. - If a character set is specified at the column level, it is applied to this column only.
- The column length specified in the table creation statement is counted at the character level,
not at the encoding byte level. - If "utf8" is used on a CHAR(n) column, this column will require 3*n bytes of storage.
Transmitting Non ASCII Characters to the Server
Handling non ASCII characters with MySQL not only requires us setting up the table columns
with the correct encoding (character set), but also requires us setting up the correct encoding
for transferring characters to and from the database.
MySQL offers the following variables to control the encodings used to transfer characters between
the client (PHP script) and the server (MySQL database):
- character_set_server - Character set used for all databases on the server.
- character_set_database - Character set used for the default databases on the server.
- character_set_client - Character set used by the client for all SQL statements.
- character_set_connection - Character set that all SQL statements should be converted to
by the server before executing them. - character_set_results - Character set that all returning result should be converted to
by the server before sending it back to the client.
In most cases, you should make the client (PHP script) to use the same encoding (character set)
as the server (MySQL server), so that there is no need to convert when transferring characters between them.
Some times, you may need to use different encodings. For example, you want to use UTF-8 for your PHP scripts,
while using GB2312 for your MySQL tables.
You can use two special SET commands to change those variables:
1. "SET NAMES 'x'" is equivalent to these three statements:
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;
2. "SET CHARACTER SET x" is equivalent to these three statements:
SET character_set_client = x;
SET character_set_results = x;
SET collation_connection = @@collation_database;
You can always use the SHOW VARIABLES LIKE 'variable_name' to view the current value of the given variable.
MySqlUnicode.php - UTF-8 Sample Script
My is my sample script to show you how to send UTF-8 strings to a MySQL server and store them
in UTF-8 encoding, MySqlUnicode.php:
<?php # MySqlUnicode.php
# Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/
#
$con = mysql_connect('localhost');
print "\nDefault settings...\n";
$rs = mysql_query("SHOW VARIABLES LIKE 'character_set_%'");
while ($row = mysql_fetch_array($rs)) {
print " ".$row[0].' '.$row[1]."\n";
}
print "\nUpdated settings...\n";
$rs = mysql_query("SET NAMES 'utf8'");
$rs = mysql_query("SHOW VARIABLES LIKE 'character_set_%'");
while ($row = mysql_fetch_array($rs)) {
print " ".$row[0].' '.$row[1]."\n";
}
print "\nCreating a table in UTF-8...\n";
$rs = mysql_query('DROP DATABASE MyBase');
$rs = mysql_query('CREATE DATABASE MyBase CHARACTER SET utf8');
$rs = mysql_query('USE MyBase');
$rs = mysql_query('CREATE TABLE MyTable (ID INTEGER,'
.' Message VARCHAR(80))');
print "\nInserting some rows to the table...\n";
$str = "Hello!";
$rs = mysql_query("INSERT INTO MyTable VALUES ( 1, '$str')");
$str = "\xC2\xA1Hola!";
$rs = mysql_query("INSERT INTO MyTable VALUES ( 2, '$str')");
$str = "\xE4\xBD\xA0\xE5\xA5\xBD!";
$rs = mysql_query("INSERT INTO MyTable VALUES ( 3, '$str')");
print "\nQuery some rows from the table...\n";
$rs = mysql_query('SELECT * FROM MyTable WHERE ID < 10');
print " ".mysql_field_name($rs,0)." "
.mysql_field_name($rs,1)."\n";
while ($row = mysql_fetch_array($rs)) {
print " ".$row[0].' '.$row[1]."=(\x".bin2hex($row[1]).")\n";
}
mysql_free_result($rs);
mysql_close($con);
?>
If you run it, you will get:
Default settings...
character_set_client latin1
character_set_connection latin1
character_set_database latin1
character_set_results latin1
character_set_server latin1
character_set_system utf8
character_sets_dir C:\local\MySQL\share\charsets/
Updated settings...
character_set_client utf8
character_set_connection utf8
character_set_database latin1
character_set_results utf8
character_set_server latin1
character_set_system utf8
character_sets_dir C:\local\MySQL\share\charsets/
Creating a table in UTF-8...
Inserting some rows to the table...
Query some rows from the table...
ID Message
1 Hello!=(\x48656c6c6f21)
2 -íHola!=(\xc2a1486f6c6121)
3 S+ásÑ+!=(\xe4bda0e5a5bd21)
MySQL works as we expected, no conversion on the SQL statements, storing strings in UTF-8, and no conversion
on query result.
Conclusion
- MySQL provides a good support on non ASCII characters. If offers a number of encodings (character sets).
- MySQL allows to specify encodings at database, table or column level.
- MySQL allows to control encoding conversions on receiving SQL statements and returning query results.
- My recommendation is to use UTF-8 to all text information, turn off MySQL encoding conversion on receiving
SQL statements and returning query results, and let your PHP script to handle UTF-8 strings.
Tuesday, June 19, 2007
Introduction to Application Object in ASP.NET
Before we understand the events, we need to know the steps that a Web request goes through during its life cycle. The request begins with the client browser and continues till the request is completely processed and the response (if any) is sent back to the client.
Order of execution
This lifecycle is called the ASP.NET pipeline. Here is how the pipeline looks. It is a step-by-step process through which various parts of the request are processed in a structured manner.
The order is as follows:
Events
Here are the types of events.
1. Events which always occur for every request
a. Request related events
b. Response related events
2. Events which occur only under certain conditions
Events which occur for each request
a) Request related events:
These events occur when a new request is received. These are listed in the order of occurrence.
Event: Application_OnBeginRequest
Comment: Raised for each request. Even for Web service requests
Event: Application_OnAuthenticateRequest
Comment: Raised when authentication is about to begin
Practical Usage: Use this to override the default authentication mechanism and write completely custom authentication code here.

When do you use this? When you require an authentication mechanism that does not fit into the default authentication methodologies given with .NET.
Further, you can use this during the development phase to quickly override the base authentication mechanism.
During production phase, simply remove this event code.
Event:Application_OnAuthorizeRequest
Comment:Raised when authorisation is about to begin. This decides what privileges to offer the current requestor.
Practical Usage: Again used to override the default authorisation and replace it with custom authorisation.
Event: Application_OnResolveRequestCache
Comment: This one is used in Page Caching. Page Caching stores page output in a cache and later serves similar requests from the cache. This increases performance dramatically.
This event is used by ASP.NET to decide whether to rerun the page code or deliver the page from the cache.
Practical Usage: Writing code for this event allows you to customise how page caching works. Further it also allows you to write code that can execute for each request, irrespective of whether the page was delivered from page cache or from the ASPX page.
For example, you can use this for generating an audit trail or performance log or for incrementing online page view counters.
Event: Application_OnAcquireRequestState
Comment: Event fires when the Session state is about to be populated for the request.
Practical Usage: Your code can customise the content of the Session stateThis is done when you want a pre-created custom item to be inserted in the Session state. This can then be handled by the page or Web service.
This will centralise the code that we often write in the page level events.
It is important to cross check with your existing code, to judge which piece of code can be better handled in this event.
Event: Application_OnPreRequestHandlerExecute
Comment:Before the page handler (or Web service handler) is called for the incoming request.
Practical Usage: Useful if you want to perform some operations before the default page handler takes over.
b) Response related events:
Event: Application_OnUpdateRequestCache
Comment:This is raised when ASP.NET decides to update the Page Output cache by actually executing a page.
Practical Usage: Write custom code here to monitor cache refresh rate (to judge the effectiveness of page caching in your application).
Event: Application_OnReleaseRequestState
Comment:Occurs when the Session data is released.
Practical Usage: Custom objects created on OnRequestState can be now handled.
Event: Application_OnPostRequestHandlerExecute
Comment: Raised after the default handler finishes execution.
Practical Usage: Used to create custom HTTP header and body.
Event: Application_OnEndRequest
Comment: Corresponding to BeginRequest.

Practical Usage: Last event to fire. Cleanup tasks are best done here.
If you want to add something to ALL pages within an application do it here.
Event: PreSendRequestHeaders and PreSendRequestContent
Comment: These events fire after the entire data is ready to be sent as the client response.
Practical Usage: Pre-event is fired when HTTP headers are sent. If you want to change any content, you must update the operation before this event fires. Otherwise, wrong size information would be sent in the header.
The content event fires after the entire body text is sent to the client.
Of all these events the EndRequest event is guaranteed to occur. This event is the place which you should use to perform tasks which require to be done after request completion – including cleanup, in this event code.
Conditional events
Event: Application_OnStart
Comment: This one is familiar to all ASP developers. This occurs only once per application when it starts. Practical Usage: One-time tasks can be done here. These could be data connections, adding data that is likely to be used frequently to cache objects, setting values for variables and so on.
Event: Application_OnEnd
Comment: Occurs when application ends.
Practical Usage: Generally used to cleanup things that were set up during the application execution period.
Event: Session_OnStart
Comment: Fires for each user when the session begins.
Practical Usage: Setting user specific values, caching items based upon user context.
Event: Session_OnEnd
Comment: Opposite of the previous event.
Practical Usage: User Specific Cleanup, audit trail, usage statistics, logging how the state terminated and so on.
Event: Application_Error
Comment: When unhandled error occurs.
Practical Usage: Good for logging errors, logging additional environmental information, notifying administrators depending upon type of error, taking global actions to manage impact of errors.
Event: Application_OnDisposed
Comment: Occurs when CRL removes the application from memory.
Practical Usage: Additional cleanup procedures.
CompleteRequest method
This method is used to bypass normal processing of the HTTP request. If you handle some event with custom code and then you do not want the control to pass to further default event handlers in the request processing chain, call this method. This method, when called, ignores all further handlers and then raises EndRequest event.
HTTP modules
Handlers for various HTTP functions are configured using HTTPModules. These modules are defined in ‘machine.config’ and can be overridden in ‘web.config’.
Various modules are utilised in serving a particular request. It is possible to write your own custom HTTP modules for implementing special functionality not available within .NET.
The HTTP handler is the class which manages the actual HTTP request. By default this is the page class in ‘system.web.ui.page’ namespace.
To create an HTTP module, you need to write a class which implements the IHTTPModule interface. To inform the runtime to use the custom module, you need to modify the ‘web.config’ file.
Handlers for various types of files are mapped in IIS application configuration settings.
The diagram below shows the ASP.NET file extensions and the relevant handlers.
Global.ASAX
All the custom code for overriding the Application events is written here. This file is optional. But if you need to customise the application event management logic, you need to create this and write code in it.
Thursday, June 14, 2007
MS SQL SERVER 2000 Questions (Database Design)
As the name indicates, denormalization is the reverse process of normalization. It's the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.
How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.
One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.
Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.
It will be a good idea to read up a database designing fundamentals text book.
What's the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.
What are user defined datatypes and when you should go for them?
User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called Flight_Num which appears in many tables. In all these tables it should be varchar(8). In this case you could create a user defined datatype called Flight_num_type of varchar(8) and use it across all your tables.
See sp_addtype, sp_droptype in books online.
What is bit datatype and what's the information that can be stored inside a bit column?
Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit datatype can represent a third state, which is NULL.
Define candidate key, alternate key, composite key.
A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.
A key formed by combining at least two or more columns is called composite key.
What are defaults? Is there a column to which a default can't be bound?
A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them. See CREATE DEFUALT in books online.
ASP Date() And Time() Functions
Returns the current date & time like this ....
6/5/2007 6:34:52 AM
--------------------------------------------------------------------------------
Returns the current date like this ....
6/5/2007
--------------------------------------------------------------------------------
Returns the current time like this ....
6:34:52 AM
--------------------------------------------------------------------------------
Returns the current year like this ....
2007
--------------------------------------------------------------------------------
Returns the current month like this ....
6
--------------------------------------------------------------------------------
Returns the current day like this ....
5
--------------------------------------------------------------------------------
Returns the current hour like this ....
6
--------------------------------------------------------------------------------
Returns the current minute like this ....
34
--------------------------------------------------------------------------------
Returns the current second like this ....
52
--------------------------------------------------------------------------------
Ok ..... You got the hang of that? We will now start jazzing things up a bit.
Returns the current date & time like this ....
6/5/2007 6:34:52 AM
--------------------------------------------------------------------------------
Returns the current date like this ....
Tuesday, June 05, 2007
--------------------------------------------------------------------------------
Returns the current date like this ....
6/5/2007
--------------------------------------------------------------------------------
Returns the current time like this ....
6:34:52 AM
--------------------------------------------------------------------------------
Returns the current time like this ....
06:34
--------------------------------------------------------------------------------
Returns the current month like this ....
June
--------------------------------------------------------------------------------
Returns the current month like this ....
Jun
--------------------------------------------------------------------------------
Returns the current day like this ....
3
--------------------------------------------------------------------------------
Returns the current day like this ....
Tuesday
--------------------------------------------------------------------------------
Returns the current day like this ....
Tue
--------------------------------------------------------------------------------
OK ... Let's take all this a little further
Returns what the date will be in 10 days time like this ....
6/15/2007 6:34:52 AM
--------------------------------------------------------------------------------
Returns what the date was 3 days ago like this ....
6/2/2007 6:34:52 AM
--------------------------------------------------------------------------------
Returns the number of days that have passed since the 24th of March 2002
1899
--------------------------------------------------------------------------------
Returns the date in typical UK format
5/6/2007
--------------------------------------------------------------------------------
Returns the date in typical USA format
6/5/2007
--------------------------------------------------------------------------------
Returns today's date like this ......
Tuesday, 5 June, 2007
ASP String Functions
String functions are a great way to manipulate and parse the data within your strings, below are some of the most commonly used ones. For our purposes, we will use this variable as an example:
strExample = "These are examples of string functions."
InStr
//Code
DIM strPosition
strPosition = InStr(1, strExample, "examples", 1)
Response.Write strPosition
//Code
In this example, our script returns the value: 11 . The InStr function is a powerful tool that searches text strings and returns the position of a given text substring. In this case, we search the strPosition string for the "example" and our script returns "11", which is the starting position of the word within the string.
Left
//Code
DIM strLeftText
strLeftText = Left(strExample, 18)
Response.Write strLeftText
//Code
In this example, our script returns the value: " These are examples ". The Left function takes a string and returns a specified number of characters starting from the left side.
Right
//Code
DIM strRightText
strRightText = Right(strExample, 10)
Response.Write strRightText
//Code
In this example, our script returns the value: " functions. ". The Right function takes a string and returns a specified number of characters starting from the end of the string.
Mid
//Code
DIM strMidText
strMidText = Mid(strExample, 11, 8)
Response.Write strMidText
//Code
In this example, our script returns the value: " examples ". The Right function takes a string and returns a specified number of characters starting from the end of the string.
Trim, LTrim, and RTrim
//Code
DIM strTrimText, strLTrimText, strRTrimText
strTrimText = Trim(strExample)
strLTrimText = LTrim(strExample)
strRTrimText = RTrim(strExample)
Response.Write strTrimText
Response.Write strLTrimText
Response.Write strRTrimText
//Code
In this example, all three atrTrimText, strLTrimText, and strRTrimText return our original example: "These are examples of string functions." LTrim is used to remove blank spaces at the beginning of a string. RTrim is used to remove blank spaces at the end of a string. Trim is used to remove spaces from both the beginning and the end of a string.
LCase and UCase
//Code
DIM strLCaseText, strUCaseText
strLCaseText = LCase(strExample)
strUCaseText = UCase(strExample)
Response.Write strLTrimText
Response.Write strRTrimText
//Code
In this example, strLCaseText returns the value: " these are examples of string functions. " and strUCaseText returns the value: " THESE ARE EXAMPLES OF STRING FUNCTIONS. ". As you can tell, the LCase function returns all lower case letters and the UCase function returns all upper case letters. These functions are especially useful for inserting and updating records in your database because they help keep your data consistent.
Len
//Code
DIM intLenText
intLenText = Len(strExample)
Response.Write intLenText
//Code
In this example, intLenExample returns the value: " 39 " . The Len function returns the number of characters in a given string.
String
//Code
DIM strMyExample
strMyExample = String(1, 97)
Response.Write strMyExample
//Code
In this example, strMyExample returns the value: " a " . The String function takes a character code (97) and returns its character (a). The (1) in this case controls how many time the "a" will be displayed.
Wednesday, June 13, 2007
Use of Regular Expression in Javascript
var fnameRegxp = /^([a-zA-Z]+)$/;
This statement checks that only upper or lowercase case letters, repeated one or more times, pass the validation test, which, unless you’re hoping to send your newsletter to C3PO, should be the case. Remember when I mentioned that regular expressions can still return true if there are incorrect characters present, provided that the correct pattern of characters is somewhere within the string? Putting the circumflex and dollar sign at the beginning and end of the regular expression ensures that this does not happen, and that the string is only valid if it contains just what you’re asking for.
var lnameRegxp = /^([a-zA-Z]+)$/;
var houseRegxp = /^([0-9A-Za-z]+)$/;
These then check that the surname entered is also any upper or lowercase character repeated one or more times, and that the house name consists of just numbers and letters. You could have shortened this to /^([\w]+)$/ using the shorthand escape code for "any word character," but that would allow underscores to be used, which rarely feature in property names.
var pcodeRegxp = /^([A-Za-z]{1,2})([0-9]{2,3})([A-Za-z]{2})$/;
var telnoRegxp = /^([0-9]{11})$/;
I’ve used local examples for the post code (the UK version of a zip code) and telephone regular expressions. UK postcodes are in a format consisting of one or two letters, followed by two or three numbers (depending on the county), and followed again by two letters. It should be easy to see how you could change this to match your own local form of postal or zip code and telephone number formats. The phone number check simply ensures that the correct number of numbers is present. Following these comes the most complex of regular expressions -- those that check for valid email addresses and URLs:
var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+)/;
Due to sub-domains, there may be any number of characters and dots preceding the @ sign. The first of these expressions says that any word character displayed one or more times can then be followed by a dot, then any number of word characters displayed zero or more times, followed by the @ symbol, followed by any word character displayed one or more times, followed by a dot and two or three word characters repeated at least once but no more than twice, so email addresses ending in .com or .co.uk will pass, whereas .co.uk.com would fail. Similarly, the URL may begin with either http://www. or https://www. or ftp://www. or just www. once followed by any word character one or more times, followed by a dot and any number of word characters at least once but no more than twice.
Finally, the date of birth check allows dates in the format dd/mm/yyyy or dd-mm-yyyy, both formats being equally as popular:
var dobRegxp = /^([0-9]){2}(\/|-){1}([0-9]){2}(\/|-)([0-9]){4}$/;
We then need to actually test that each of the values submitted are in the correct format. I accomplished this by using a series of nested if statements and alerts. This method is useful for demonstration and testing purposes, although in reality, a for…next loop would probably be more efficient, and some kind of color highlighting scheme that would flag the erroneous input values a different color, say red, on the form itself would be more professional. The example if statements and alerts however, can be constructed as follows:
if (fnameRegxp.test(fname) != true)
alert("First name appears to be incorrect");
if (lnameRegxp.test(lname) != true)
alert("Last name appears to be incorrect");
if (houseRegxp.test(house) != true)
alert("Address 1 appears to be incorrect");
if (pcodeRegxp.test(pcode) != true)
alert("Address 2 appears to be incorrect");
if (telnoRegxp.test(telno) != true)
alert("Telephone number appears to be incorrect");
if (emailRegxp.test(email) != true)
alert("Email address appears to be incorrect");
if (email != verEmail)
alert("Email appears to be incorrect");
if (urlRegxp.test(url) != true)
alert("URL appears to be incorrect");
if (dobRegxp.test(dob) != true)
alert("Date of Birth appears to be incorrect");
Notice that instead of using a regular expression to check that the second email address entered (that should be the same as the first for verification purposes) is correct, we simply check that its value is exactly the same as the first email address entered.
Finally, if all of the data is in the correct format, we need this program to output a "Data Correct" alert and change the value of the action property of the form to the name of the cgi function that will process the data. Once again, against a professional backdrop, the true alert would probably be removed in favor of a fresh page thanking the visitor for their time, but this is useful for demonstration and
testing purposes:
else {
alert("Data Correct");
document.myForm.action.value = "process.cgi";
}
}
Another benefit to using regular expressions to validate user input is that any fields that are checked against a regular expression fail if the field is left blank, so you don’t have to write any separate omission checking functions.
Explaining regular expressions is almost as difficult as coding them. It will be far easier for you to see what I mean by writing and playing around with them yourself. Unfortunately, it is not possible to be 100 percent certain that all information entered is correct, but with regular expressions you can at least be sure that 99 percent of the data is correct.
Although this may seem like a cumbersome amount of code, without regular expressions, it would be ten times as long. Using client-side validation is not the securest way to validate your forms, but it may save processing time on your server by ensuring that only correct data is passed to it in the first place. Other than that, JavaScript is both quick and easy to implement and the regular expressions subset of the language is simpler than that of some of the more powerful Web programming languages, so for sites that don’t need maximum security, it is certainly worth considering.
.NET Tech Questions
• Windows 2000, Windows Server 2003 or Windows XP.
• ASP.NET, which can be either the redistributable (included in the .NET SDK) or Visual Studio .NET.
1. Where can I download the .NET SDK?
.NET SDK can be obtained here.
(You have to install the Microsoft .NET Framework Version 1.1 Redistributable Package before installing the .NET SDK.)
2. Are there any free IDEs for the .NET SDK?
o Microsoft provides Visual Studio 2005 Express Edition Beta for free. Of particular interest to the ASP.NET developers would be the Visual Web Developer 2005 Express Edition Beta 2 available as a free download.
o The ASP.NET Web Matrix Project (supported by Microsoft) is a free IDE for developing ASP.NET applications and is available here.
o There is also a free open-source UNIX version of the Microsoft .NET development platform called Mono available for download here.
o Another increasingly popular Open Source Development Environment for .NET is the #develop (short for SharpDevelop) available for download here.
3. When was ASP.NET released?
ASP.NET is a part of the .NET framework which was released as a software platform in 2002.
4. Is a new version coming up?
ASP.NET 2.0, Visual Studio 2005 (Whidbey), Visual Web Developer 2005 Express Edition are the next releases of Microsoft's Web platform and tools. They have already been released as Beta versions. They are scheduled to be released in the week of November 7, 2005.
5. Explain Namespace.
Namespaces are logical groupings of names used within a program. There may be multiple namespaces in a single application code, grouped based on the identifiers’ use. The name of any given identifier must appear only once in its namespace.
6. List the types of Authentication supported by ASP.NET.
o Windows (default)
o Forms
o Passport
o None (Security disabled)
7. What is CLR?
Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging, security, etc. The CLR is also known as Virtual Execution System (VES).
8. What is CLI?
The CLI is a set of specifications for a runtime environment, including a common type system, base class library, and a machine-independent intermediate code known as the Common Intermediate Language (CIL). (Source: Wikipedia.)
9. List the various stages of Page-Load lifecycle.
o Init()
o Load()
o PreRender()
o Unload()
10. Explain Assembly and Manifest.
An assembly is a collection of one or more files and one of them (DLL or EXE) contains a special metadata called Assembly Manifest. The manifest is stored as binary data and contains details like versioning requirements for the assembly, the author, security permissions, and list of files forming the assembly. An assembly is created whenever a DLL is built. The manifest can be viewed programmatically by making use of classes from the System.Reflection namespace. The tool Intermediate Language Disassembler (ILDASM) can be used for this purpose. It can be launched from the command prompt or via Start> Run.
11. What is Shadow Copy?
In order to replace a COM component on a live web server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components are different. They can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the currently executing requests. By bleeding out the older version, the update is completed.
12. What is DLL Hell?
DLL hell is the problem that occurs when an installation of a newer application might break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side component versioning.
13. Explain Web Services.
Web services are programmable business logic components that provide access to functionality through the Internet. Standard protocols like HTTP can be used to access them. Web services are based on the Simple Object Access Protocol (SOAP), which is an application of XML. Web services are given the .asmx extension.
14. Explain Windows Forms.
Windows Forms is employed for developing Windows GUI applications. It is a class library that gives developers access to Windows Common Controls with rich functionality. It is a common GUI library for all the languages supported by the .NET Framework.
15. What is Postback?
When an action occurs (like button click), the page containing all the controls within the tag performs an HTTP POST, while having itself as the target URL. This is called Postback.
16. Explain the differences between server-side and client-side code?
Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.
17. Enumerate the types of Directives.
o @ Page directive
o @ Import directive
o @ Implements directive
o @ Register directive
o @ Assembly directive
o @ OutputCache directive
o @ Reference directive
18. What is Code-Behind?
Code-Behind is a concept where the contents of a page are in one file and the server-side code is in another. This allows different people to work on the same page at the same time and also allows either part of the page to be easily redesigned, with no changes required in the other. An Inherits attribute is added to the @ Page directive to specify the location of the Code-Behind file to the ASP.NET page.
19. Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. There is no separate distinction between design code and logic code. Code-behind is code written in a separate file and referenced by the .aspx page.
20. List the ASP.NET validation controls?
o RequiredFieldValidator
o RangeValidator
o CompareValidator
o RegularExpressionValidator
o CustomValidator
o ValidationSummary
21. What is Data Binding?
Data binding is a way used to connect values from a collection of data (e.g. DataSet) to the controls on a web form. The values from the dataset are automatically displayed in the controls without having to write separate code to display them.
22. Describe Paging in ASP.NET.
The DataGrid control in ASP.NET enables easy paging of the data. The AllowPaging property of the DataGrid can be set to True to perform paging. ASP.NET automatically performs paging and provides the hyperlinks to the other pages in different styles, based on the property that has been set for PagerStyle.Mode.
23. Should user input data validation occur server-side or client-side? Why?
All user input data validation should occur on the server and minimally on the client-side, though it is a good way to reduce server load and network traffic because we can ensure that only data of the appropriate type is submitted from the form. It is totally insecure. The user can view the code used for validation and create a workaround for it. Secondly, the URL of the page that handles the data is freely visible in the original form page. This will allow unscrupulous users to send data from their own forms to your application. Client-side validation can sometimes be performed where deemed appropriate and feasible to provide a richer, more responsive experience for the user.
24. What is the difference between Server.Transfer and Response.Redirect?
o Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
o Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.
26. What is an interface and what is an abstract class?
In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.
27. Session state vs. View state:
In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:
o Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
o Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
o Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
28. Can two different programming languages be mixed in a single ASPX file?
ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.
29. Is it possible to see the code that ASP.NET generates from an ASPX file?
By enabling debugging using a directive in the ASPX file or a statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).
30. Can a custom .NET data type be used in a Web form?
This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.
31. List the event handlers that can be included in Global.asax?
o Application start and end event handlers
o Session start and end event handlers
o Per-request event handlers
o Non-deterministic event handlers
32. Can the view state be protected from tampering?
This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the statement in the Web.config file.
33. Can the view state be encrypted?
The view state can be encrypted by setting EnableViewStateMac to true and either modifying the element in Machine.config to "
34. When during the page processing cycle is ViewState available?
The view state is available after the Init() and before the Render() methods are called during Page load.
35. Do Web controls support Cascading Style Sheets?
All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.
36. What namespaces are imported by default in ASPX files?
The following namespaces are imported by default. Other namespaces must be imported manually using @ Import directives.
o System
o System.Collections
o System.Collections.Specialized
o System.Configuration
o System.Text
o System.Text.RegularExpressions
o System.Web
o System.Web.Caching
o System.Web.Security
o System.Web.SessionState
o System.Web.UI
o System.Web.UI.HtmlControls
o System.Web.UI.WebControls
37. What classes are needed to send e-mail from an ASP.NET application?
The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mail namespace.
38. Why do some web service classes derive from System.Web.WebServices while others do not?
Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.
39. What are VSDISCO files?
VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.
40. How can files be uploaded to Web pages in ASP.NET?
This can be done by using the HtmlInputFile class to declare an instance of an tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.
41. How do I create an ASPX page that periodically refreshes itself?
The following META tag can be used as a trigger to automatically refresh the page every n seconds:
42. How do I initialize a TextBox whose TextMode is "password", with a password?
The TextBox’s Text property cannot be used to assign a value to a password field. Instead, its Value field can be used for that purpose.
ID="Password" RunAt="server" />
43. Why does the control's PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?
This occurs when an enctype="multipart/form-data" attribute is missing in the
tag.
44. How can the focus be set to a specific control when a Web form loads?
This can be achieved by using client-side script:
document.forms[0].TextBox1.focus ()
The above code will set the focus to a TextBox named TextBox1 when the page loads.
45. How does System.Web.UI.Page's IsPostBack property work?
IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.
46. What is WSDL?
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)
47. What is UDDI?
UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.
48. Is it possible to generate the source code for an ASP.NET Web service from a WSDL?
The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.
Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.
49. Why do uploads fail while using an ASP.NET file upload control to upload large files?
ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.config's element.
50. Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.
51. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
52. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Valid answers are:
o A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
o A DataSet is designed to work without any continuing connection to the original data source.
o Data in a DataSet is bulk-loaded, rather than being loaded on demand.
o There's no concept of cursor types in a DataSet.
o DataSets have no current record pointer You can use For Each loops to move through the data.
o You can store many edits in a DataSet, and write them to the original data source in a single operation.
o Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
53. What’s a bubbled event?
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
54. What data types do the RangeValidator control support?
Integer, String, and Date.
55. Explain what a diffgram is, and a good use for one?
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.
56. What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.
57. What is ViewState?
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.
58. What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.
59. What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.
60. Differences Between XML and HTML?
Anyone with a fundamental grasp of XML should be able describe some of the main differences outlined in the table below
XML HTML
User definable tags Defined set of tags designed for web display
Content driven Format driven
End tags required for well formed documents End tags not required
Quotes required around attributes values Quotes not required
Slash required in empty tags Slash not required
61. Give a few examples of types of applications that can benefit from using XML.
There are literally thousands of applications that can benefit from XML technologies. The point of this question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.
62. What is DOM and how does it relate to XML?
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.
63. What is SOAP and how does it relate to XML?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.
64. Can you walk us through the steps necessary to parse XML documents?
Superficially, this is a fairly basic question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate's response.
65. What are possible implementations of distributed applications in .NET?
.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.
66. What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.
67. What’s a proxy of the server object in .NET Remoting?
It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.
68. What are remotable objects in .NET Remoting?
Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.
69. What are channels in .NET Remoting?
Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
70. What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
71. What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
72. Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?
Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
73. What’s SingleCall activation mode used for?
If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
74. What’s Singleton activation mode?
A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.
75. How do you define the lease of the object?
By implementing ILease interface when writing the class code.
76. Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
77. How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.
ASP.NET 2.0 Tech Questions
Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview.
2. What are the new Navigation Controls in Asp.net 2.0?
The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.
3. What are the new Login Controlsin Asp.net 2.0?
The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.
4. What are the new Web Part Controls in Asp.net 2.0 ?
Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.
5. What are Master Pages?
This feature provides the ability to define common structure and interface elements for your site, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behavior.
6. What are Themes and Skins in 2.0, explain usgae scenario?
The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles.
7. What is a profile object, why is it used?
Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for user accounts and build highly customized, relationship based experiences. At the same time, a developer can leverage Web Parts and the personalization service to enable Web site visitors to completely control the layout and behavior of the site, with the knowledge that the site is completely customized for them. Personalizaton scenarios are now easier to build than ever before and require significantly less code and effort to implement.
8. What is Configuration API?
ASP.NET 2.0 contains new configuration management APIs, enabling users to programmatically build programs or scripts that create, read, and update Web.config and machine.config configuration files.
9. What is MMC Admin Tool?
ASP.NET 2.0 provides a new comprehensive admin tool that plugs into the existing IIS Administration MMC, enabling an administrator to graphically read or change common settings within our XML configuration files.
10. Explain the use of Pre-compilation Tool?
ASP.NET 2.0 delivers a new application deployment utility that enables both developers and administrators to precompile a dynamic ASP.NET application prior to deployment. This precompilation automatically identifies any compilation issues anywhere within the site, as well as enables ASP.NET applications to be deployed without any source being stored on the server (one can optionally remove the content of .aspx files as part of the compile phase), further protecting your intellectual property.
11. How is application management and maintenance improved in Asp.net 2.0?
ASP.NET 2.0 also provides new health-monitoring support to enable administrators to be automatically notified when an application on a server starts to experience problems. New tracing features will enable administrators to capture run-time and request data from a production server to better diagnose issues. ASP.NET 2.0 is delivering features that will enable developers and administrators to simplify the day-to-day management and maintenance of their Web applications.
12. What are Provider-driven Application Services? explain in detail?
ASP.NET 2.0 now includes built-in support for membership (user name/password credential storage) and role management services out of the box. The new personalization service enables quick storage/retrieval of user settings and preferences, facilitating rich customization with minimal code. The new site navigation system enables developers to quickly build link structures consistently across a site. As all of these services are provider-driven, they can be easily swapped out and replaced with your own custom implementation. With this extensibility option, you have complete control over the data store and schema that drives these rich application services.
13. Explain Server Control Extensibility with reference to Asp.net 2.0 ?
ASP.NET 2.0 includes improved support for control extensibility, such as more base classes that encapsulate common behaviors, improved designer support, more APIs for interacting with client-side script, metadata-driven support for new features like themes and accessibility verification, better state management, and more.
14. What are the Data Source Controls?
Data access in ASP.NET 2.0 is now performed declaratively using data source controls on a page. In this model, support for new data backend storage providers can be easily added by implementing custom data source controls. Additionally, the SqlDataSource control that ships in the box has built-in support for any ADO.NET managed provider that implements the new provider factory model in ADO.NET.
15. What are Compilation Build Providers?
Dynamic compilation in ASP.NET 2.0 is now handled by extensible compilation build providers, which associate a particular file extension with a handler that knows how to compile that extension dynamically at runtime. For example, .resx files can be dynamically compiled to resources, .wsdl files to web service proxies, and .xsd files to typed DataSet objects. In addition to the built-in support, it is easy to add support for additional extensions by implementing a custom build provider and registering it in Web.config.
16. What is Expression Builders, why would you use it?
ASP.NET 2.0 introduces a declarative new syntax for referencing code to substitute values into the page, called Expression Builders. ASP.NET 2.0 includes expression builders for referencing string resources for localization, connection strings, application settings, and profile values. You can also write your own expression builders to create your own custom syntax to substitute values in a page rendering.
17. Is ASP.NET 64-Bit enabled? how?
ASP.NET 2.0 is now 64-bit enabled, meaning it can take advantage of the full memory address space of new 64-bit processors and servers. Developers can simply copy existing 32-bit ASP.NET applications onto a 64-bit ASP.NET 2.0 server and have them automatically be JIT compiled and executed as native 64-bit applications (no source code changes or manual re-compile are required).
18. Explain how Caching in Asp.net 2.0 is different from Caching in Asp.net 1.1?
ASP.NET 2.0 also now includes automatic database server cache invalidation. This powerful and easy-to-use feature allows developers to aggressively output cache database-driven page and partial page content within a site and have ASP.NET automatically invalidate these cache entries and refresh the content whenever the back-end database changes. Developers can now safely cache time-critical content for long periods without worrying about serving visitors stale data.