1. configuring ASP.NET with IIS.
cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
aspnet_regiis.exe –i
2. Even if u use 3.5 version go for v2.0.50727 and run aspnet_regiis.exe because there is no executable with the name aspnet_regiis.exe in 3.5.
3. While creating new website in ASP.NET, If you choose an HTTP location (such as http://www.example.com), the web application will be executed through IIS.
If you choose the file system, you need to choose a physical location on your disk, application is executed using Visual Studio’s integrated web server.
4. After making a column an identity column, SQL Server will not allow you, by default, to add values to that column manually. This is why you’ll find, typically in SQL table creation scripts, commands like the following, which are used to temporarily enable inserting custom data to the identity column:
SET IDENTITY_INSERT Departments ON
5. The generated values for identity columns are unique over the life of your table. A value that was generated once will never be generated again, even if you delete all the rows from the table. If you want SQL Server to restart numbering from the initial value, you need to either delete and re-create the table or truncate the table using the TRUNCATE SQL command. Truncating a table has the same effect as deleting and creating it again.
6. indexes speed up table reads, but they slow down insert, delete, and update operations—because on those operations, the database server needs to alter not only the table, but also the additional structures created by its index (or indexes).
7. The INTO keyword in INSERT is optional, but including it makes the statement easier to read.
8. Database Connection:
// Create the connection object
SqlConnection connection = new SqlConnection();
// Set the connection string
connection.ConnectionString = "Server=(local)\SqlExpress; " +"User ID=username; Password=password;" +
"Database=dbname"; ---------------------SQL Server Authentication
// Open the connection
connection.Open();
Integrated Security=True
(or Integrated Security=SSPI) instead of User ID=username; Password=password. For Windows Authentication,
9. readonly is different from const The major similarity between the readonly and const fields is that you aren’t allowed to change their values
inside class methods or properties. The main difference is that whereas for constants you need to set their value at
the time you write the code (their values must be known at compile-time), with readonly fields you are allowed to dynamically set their values in the class constructor.
10. string is an alias for System.String. They compile to the same code, so at execution time there is no difference whatsoever. This is just one of the aliases in C#. The complete list is:
• object: System.Object
• string: System.String
• bool: System.Boolean
• byte: System.Byte
• sbyte: System.SByte
• short: System.Int16
• ushort: System.UInt16
• int: System.Int32
• uint: System.UInt32
• long: System.Int64
• ulong: System.UInt64
• float: System.Single
• double: System.Double
• decimal: System.Decimal
• char: System.Char
Apart from string and object, the aliases are all to value types.
Apart from string, object and decimal, the aliases are all to value types. The only primitive type which doesn't have an alias is System.IntPtr.
11. This process of converting various forms of a URL to a
standard form is called URL canonicalization.
11. For typical URL rewriting scenarios, it makes sense to use one of the existing URL rewriting products—such as ISAPI_Rewrite by Helicon Tech (http://www.isapirewrite.com/) or UrlRewriter.NET (http://urlrewriter.net).
UrlRewriter.NET : This tool is an opensource
component that implements URL rewriting at the ASP.NET level, and for this reason it’s very
easy to integrate into your project. ISAPI_Rewrite, on the other hand, is implemented as an ISAPI
filter and it performs the rewrite at the IIS level. This offers great performance but it also requires
access to the server machine in order to install it.
12. the question mark (?) metacharacter specifies that the preceding character is optional. So if you want to match “color” and “colour,” your regular expression would be colou?r.
13.
The problem with ViewState is that it’s transferred between the client and the server on
every request. With pages that contain a large number of controls, the ViewState information
can grow significantly, causing a lot of network traffic. The ViewState information can be disabled
for an entire page, or just for specific controls on a page. However, when disabling ViewState
for a control, you need to fill it with data even during postback events; otherwise, its contents
1. will disappear
When you know the exact length of the strings you’re storing in a table field, it’s better to use the Char
data type than VarChar.
TryParse. This static method of the Int32 class (you can find it in other similar classes, too) is similar to
Parse, but doesn’t throw an exception if the conversion cannot be done—which can easily happen if the visitor
enters a letter instead of a number in the quantity box, for example.
TryParse returns a bool value representing the success of the operation and returns the converted value as an
out parameter:
// Get the quantity, guarding against bogus values
if (Int32.TryParse(quantityTextBox.Text, out quantity))
INSERT INTO Orders DEFAULT VALUES
set EnableViewState property to False, so its value will be cleared after a successful command executes.
Hashing is a one-way system, but to store credit card details securely, you’ll need to use a
more advanced, bidirectional form of encryption.
System.Security.Cryptography namespace in .NET contains several classes for hashing
SHA1 (Secure Hash Algorithm) generates a 160-bit hash
MD5 (Message Digest). generates a 128-bit hash
// convert password to byte array
byte[] passwordBytes =
System.Text.ASCIIEncoding.ASCII.GetBytes(password);
// generate hash from byte array of password
byte[] passwordHash = hasher.ComputeHash(passwordBytes);
// convert hash to string
return Convert.ToBase64String(passwordHash, 0, passwordHash.Length);
The two available asymmetric algorithms are DSA (Digital Signature Algorithm) and RSA
(Rivest-Shamir-Adleman, from the names of its inventors: Ronald Rivest, Adi Shamir, and
Leonard Adleman). Of these, DSA can only be used to “sign” data so that its authenticity can be
verified, whereas RSA is more versatile (although slower than DSA when used to generate digital
signatures). DSA is the current standard for digital authentication used by the U.S. government.
The symmetric algorithms found in the .NET Framework are DES (Data Encryption Standard),
Triple DES (3DES), RC2 (“Ron’s Code,” or “Rivest’s Cipher” depending on who you ask,
also from Ronald Rivest), and Rijndael (from the names of its inventors, John Daemen and
Vincent Rijman)
- Prevent Cross-Site Scripting,XSS Vulnerabilities in ASP.NET, use the floowinf in the controls that have text property
HttpUtility.HtmlEncode Method (System.Web)
- Any Data that can be serialised can be added to viewstate.
SqlMetal.exe -à to generate both dbml and O/R Code for a given database.
Sqlmetal “......\*.mdf” /language:cs /dbml:SomeName.dbml
Sqlmetal “......\*.mdf” /language:cs /dbml:SomeName.cs