Free Search Engine Submission Search Engine Submission - AddMe ASP.NET Help, ASP.NET Tutorials, ASP.NET Programming, ASP.NET Tricks

Friday, September 10, 2010

What is Web.config


Web.con fig file is a collection of settings.
like
database.
session state.
error handling
security.
if u want to do any change we can perform here so it reflect to entire project.

Example:
we develop a project for a company, that company shifted a new place so address is changed. In this time what we do simply changes in web.config file.

How You Can Create xml File?


string str = "";

string s="select * from emp";
SqlCommand cmd = new SqlCommand(s, con);
SqlDataReader dr = cmd.ExecuteReader();
//str += " <Employee>" ;
str += "";
while (dr.Read())
{
str += "";
str += dr[0].ToString();
str += "
";
str += dr[1].ToString();
str += "
";

}
str += "
";
StreamWriter sw = File.CreateText("D:\ampl.xml");
sw.WriteLine(str);
sw.Close();
What is Strong Name?


A strong name consists of the assembly's identity — its simple text name, version number, and culture information (if provided) — plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make
up the assembly), using the corresponding private key. Assemblies with the same strong name are expected to be identical.
Strong names guarantee name uniqueness by relying on unique key pairs. No one can generate the same assembly name that you can, because an assembly generated with one private key has a different name than an assembly generated with another private key.
When you reference a strong-named assembly, you expect to get certain benefits, such as versioning and naming protection. If the strong-named assembly then referencesan assembly with a simple name, which does not have these benefits, you lose the benefits you would derive from using a strong-named assembly and revert
to DLL conflicts. Therefore, strong-named assemblies can only reference other strong-named assemblies.
There are two ways to sign an assembly with a strong name:
1. Using the Assembly Linker (Al.exe) provided by the .NET Framework SDK.
2. Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute,
depending on where the key file to be used is located.
To create and sign an assembly with a strong name using the Assembly Linker, at the command prompt, type the following command:
al /out: /keyfile:
In this command, assembly name is the name of the assembly to sign with a strong name, module name is the name of the code module used to create the assembly, and file name is the name of the container or file that contains the key pair.
The following example signs the assembly MyAssembly.dll with a strong name using the key file sgKey.snk.
al /out:MyAssembly.dll MyModule.netmodule /keyfile:sgKey.snk
To sign an assembly with a strong name using attributes
In a code module, add the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, specifying the name of the file or container that contains the key pair to use when signing the assembly with a strong name. The following code example uses the AssemblyKeyFileAttribute with a key file called sgKey.snk.
[Visual Basic]

[C#]
[assembly:AssemblyKeyFileAttribute(@"....sgKey.snk")]


Strong Name is required to register the assembly into GAC. Conatins the assembly name, versoin etc. info.
      (2) What Is CTS



In order that two language communicate smoothly CLR has CTS (Common Type System).
For example in VB you have "Integer" and in C++ you have "long" these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages can communicateMicrosoft introduced Common Type System. So "Integer" datatype in VB6 and
"int" datatype in C++ will convert it to System.int32 which is datatype of CTS.

(3) What is the Difference Between ADO & ADO.Net

ADO uses Recordsets and cursors to access and modify data. Because of its inherent design, Recordset can impact performance on the server side by tying up valuable resources. In addition, COM marshalling - an expensivedata conversion process - is needed to transmit a Recordset. ADO.NET addresses three important needs that ADO doesn't address:
1. Providing a comprehensive disconnected data-access model, which is crucial to the Web environment
2. Providing tight integration with XML, and
3. Providing seamless integration with the .NET Framework(e.g., compatibility with the base class library's type system). From an ADO.NET implementation perspective, the Recordset object in ADO is eliminated in the .NET architecture. In its place, ADO.NET has several dedicated objects led by the DataSet object and including the DataAdapter, and DataReader objects to perform specific tasks. In addition, ADO.NET DataSets operate in disconnected state whereas the ADO RecordSet objects operated in a fully connected state.
In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table. In contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will typically contain multiple DataTable objects. That is, each DataTable object typically
corresponds to a single database table or view. In this way, a dataset can mimic the structure of the underlying database. In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. In ADO.NET, rows are represented as collections, so you can loop through a table as you would through any collection, or access particular rows via ordinal or primary key index. A cursor is a database element that controls record navigation, the ability to update data, and the visibility of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but instead includes data classes that provide the functionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object.
There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source.
InterView Question  & Answer 


(1) What is CLR



Full form of CLR is Common Language Runtime and it forms the heart of the .NET
framework.All Languages have runtime and its the responsibility of the runtime to take care of
the code execution of the program.For example VC++ has MSCRT40.DLL,VB6 has
MSVBVM60.DLL , Java has Java Virtual Machine etc. Similarly .NET has CLR.Following are the
responsibilities of CLR
√ Garbage Collection :- CLR automatically manages memory thus eliminating
memory leakes. When objects are not referred GC automatically releases those
memory thus providing efficient memory management.
√ Code Access Security :- CAS grants rights to program depending on the security
configuration of the machine.Example the program has rights to edit or create
a new file but the security configuration of machine does not allow the program
to delete a file.CAS will take care that the code runs under the environment of
machines security configuration.
√ Code Verification :- This ensures proper code execution and type safety while
the code runs.It prevents the Source Code to perform illegal operation such as
accessing invalid memory locations etc.
√ IL( Intermediate language )-to-native translators and optimizer?s :- CLR uses
JIT and compiles the IL code to machine code and then executes. CLR also
determines depending on platform what is optimized way of running the IL
code.