Anda di halaman 1dari 4

Whats the difference between Classic ASP and ASP.NET?

Major difference: Classic ASP is Interpreted. ASP.NET is Compiled. If code is changed,


ASP.NET recompiles, otherwise does'nt.
Other differences: ASP works with VB as the language. ASP.NET works with VB.NET & C# as
the languages (Also supported by other languages that run on the .NET Framework).
ASP.NET is the web technology that comes with the Microsoft .NET Framework. The main
process in ASP.NET is called aspnet_wp.exe that accesses system resources. ASP.NET was
launched in 2002 with version 1.0. Subsequent versions are 1.1 and version 2.0. ASP.NET is
built up using thousands of objects, ordered in the System namespace. When an ASP.NET
class is compiled, its called an assembly.
In Classic ASP, complex functionalities are achieved using COM components, that are nothing
but component objects created using VB 6, C++ etc, and are usually in a DLL format. These
components provide an exposed interface to methods in them, to the objects that reference
these components. Last version of classic ASP is version 3.0. ASP has 7 main objects -
Application, ASPError, ObjectContext, Request, Response, Server, Session.

What is the difference between ADO and ADO.NET?


The old ADO (ActiveX Data Object) has evolved to ADO.NET in the .NET Framework. The
ADO.NET object is a lightweight object. The ADO Recordset was a huge object in ADO. It
provided the ability to support multiple types of cursors. It provided fast lightweight
"firehose" cursor and also supported a disconnected client-side cursor that supported
tracking, optimistic locking, and automatic batch updates of a central database. However, all of
this functionality was difficult to customize.
ADO.NET breaks the functionality of the ADO object to multiple classes, thereby allowing a
focused approach to developing code. The ADO.NET DataReader is equivalent to the
"firehose" cursor. The DataSet is a disconnected cache with tracking and control binding
functionality. The DataAdapter provides the ability to completely customize how the central
data store is updated with the changes to a DataSet.

What is the difference between a DLL and an EXE?


In .NET, an assembly may become a DLL or an EXE. Yet, there is a major underlying difference
between the two.
An EXE is an executable file, that may run on its own. Its independant. Where as a DLL is a
Dynamic Link Library, that binds to an exe, or another DLL at runtime.
A DLL has an exposed interface, through which members of the assembly may be accessed by
those objects that require it.
A DLL runs in tandem with the application space in memory, as the application references it.
Whereas an EXE is independant, and runs as an independent process.

What is the difference between Trace and Debug?


Trace and Debug - There are two main classes that deal with tracing - Debug and Trace.
They both work in a similar way - the difference is that tracing from the Debug class only
works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class
only works in builds that have the TRACE symbol defined. Typically this means that you should
use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release
builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in
debug builds.

Tracing is actually the process of collecting information about the program's execution.
Debugging is the process of finding & fixing errors in our program. Tracing is the ability of an
application to generate information about its own execution. The idea is that subsequent
analysis of this information may help us understand why a part of the application is not
behaving as it should and allow identification of the source of the error.

We shall look at two different ways of implementing tracing in .NET via the
System.Web.TraceContext class via the System.Diagnostics.Trace and
System.Diagnostics.Debug classes. Tracing can be thought of as a better alternative to the
response.writes we used to put in our classic ASP3.0 code to help debug pages.
If we set the Tracing attribute of the Page Directive to True, then Tracing is enabled. The
output is appended in the web form output. Messeges can be displayed in the Trace output
using Trace.Warn & Trace.Write.
NOTE The only difference between Trace.Warn & Trace.Write is that the former has output in
red color. If the trace is false, there is another way to enable tracing. This is done through the
application level. We can use the web.config file and set the trace attribute to true. Here we
can set <trace enabled=false .../>
Note that the Page Directive Trace attribute has precedence over th application level trace
attribute of web.config. While using application level tracing, we can view the trace output in
the trace.axd file of the project.

What is the difference between Server.Transfer and Response.Redirect?


Both "Server" and "Response" are objects of ASP.NET. Server.Transfer and
Response.Redirect both are used to transfer a user from one page to another. But there is
an underlying difference.
//Usage of Server.Transfer & Response.Redirect
Server.Transfer("Page2.aspx");
Response.Redirect("Page2.aspx");
The Response.Redirect statement sends a command back to the browser to request the next
page from the server. This extra round-trip is often inefficient and unnecessary, but this
established standard works very well. By the time Page2 is requested, Page1 has been flushed
from the server’s memory and no information can be retrieved about it unless the developer
explicitly saved the information using some technique like session, cookie, application, cache
etc.
The more efficient Server.Transfer method simply renders the next page to the browser
without an extra round trip. Variables can stay in scope and Page2 can read properties
directly from Page1 because it’s still in memory. This technique would be ideal if it wasn’t for
the fact that the browser is never notified that the page has changed. Therefore, the address
bar in the browser will still show “Page1.aspx” even though the Server.Transfer statement
actually caused Page2.aspx to be rendered instead. This may occasionally be a good thing
from a security perspective, it often causes problems related to the browser being out of touch
with the server. Say, the user reloads the page, the browser will request Page1.aspx instead of
the true page (Page2.aspx) that they were viewing. In most cases, Response.Redirect and
Server.Transfer can be used interchangeably. But in some cases, efficiency or usability may be
the deciding factor in choosing.

What is the difference between Server.Transfer and Server.Execute?


Both Server.Transfer and Server.Execute were introduced in Classic ASP 3.0 (and still
work in ASP.NET).
When Server.Execute is used, a URL is passed to it as a parameter, and the control moves to
this new page. Execution of code happens on the new page. Once code execution gets over,
the control returns to the initial page, just after where it was called. However, in the case of
Server.Transfer, it works very much the same, the difference being the execution stops at
the new page itself (means the control is'nt returned to the calling page).
In both the cases, the URL in the browser remains the first page url (does'nt refresh to the
new page URL) as the browser is'nt requested to do so.

What is the difference between Authorization and Authentication?


Both Authentication and Authorization are concepts of providing permission to users to
maintain different levels of security, as per the application requirement.
Authentication is the mechanism whereby systems may securely identify their users.
Authentication systems depend on some unique bit of information known only to the individual
being authenticated and the authentication system.
Authorization is the mechanism by which a system determines what level of access a
particular authenticated user should have to secured resources controlled by the system.
When a user logs on to an application/system, the user is first Authenticated, and then
Authorized.
ASP.NET has 3 ways to Authenticate a user:
1) Forms Authentication
2) Windows Authentication
3) Passport Authentication (This is obsolete in .NET 2.0)
The 4th way is "None" (means no authentication)

The Authentication Provider performs the task of verifying the credentials of the user ans
decides whether a user is authenticated or not. The authentication may be set using the
web.config file.
Windows Authentication provider is the default authentication provider for ASP.NET
applications. When a user using this authentication logs in to an application, the credentials
are matched with the Windows domain through IIS.
There are 4 types of Windows Authentication methods:
1) Anonymous Authentication - IIS allows any user
2) Basic Authentication - A windows username and password has to be sent across the
network (in plain text format, hence not very secure). 3) Digest Authentication - Same as
Basic Authentication, but the credentials are encrypted. Works only on IE 5 or above
4) Integrated Windows Authentication - Relies on Kerberos technology, with strong
credential encryption

Forms Authentication - This authentication relies on code written by a developer, where


credentials are matched against a database. Credentials are entered on web forms, and are
matched with the database table that contains the user information.

Authorization in .NET - There are two types:


FileAuthorization - this depends on the NTFS system for granting permission
UrlAuthorization - Authorization rules may be explicitly specified in web.config for different
web URLs.

What is the difference between a DataReader and Dataset in ADO.NET?


A DataReader works in a connected environment, whereas DataSet works in a disconnected
environment.
A DataReader object represents a forward only, read only access to data from a source. It
implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class
can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader
method of the SQLCommand class, typically as a result of a SQL Select statement. The
DataReader class' HasRows property can be called to determine whether the DataReader
retrieved any rows from the source. This can be used before using the Read method to check
whether any data has been retrieved.
Example
Dim objCmd as New SqlCommand("Select * from t_Employees", objCon)
objCon.Open()
Dim objReader as SqlDataReader
objReader = objCom.ExecuteReader(CommandBehavior.CloseConnection)
If objReader.HasRows = True then
Do While objReader.Read()
ListBox1.Items.Add(objReader.GetString(0) & vbTab & objReader.GetInt16(1))
Loop
End If
objReader.Close()
(NOTE: XmlReader object is used for Forward only Read only access of XML).

A DataSet represents an in-memory cache of data consisting of any number of inter-related


DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a
DataRow represents a single row of a DataTable object. A Dataset is like a mini-database
engine, but its data is stored in the memory. To query the data in a DataSet, we can use a
DataView object.
Example
Dim objCon as SqlConnection = New
SqlConnection("server=(local);database=NameOfYourDb;user id=sa; password=;)
Dim da as New SqlDataAdapter
Dim ds as DataSet = New DataSet
da.SelectCommand.Connection = objCon 'The Data Adapter manages on its own, opening &
closing of connection object
da.SelectCommand.CommandText = "Select * from t_SomeTable"
da.Fill(ds,"YourTableName")

Suppose you want to bind the data in this dataset to a gridview

Gridview1.DataSource = ds
Gridview1.DataMember = "YourTableName"
Gridview1.Databind()

What is the difference between ExecuteScalar and ExecuteNonQuery? What


is ExecuteReader?
ExecuteScalar - Returns only one value after execution of the query. It returns the first field
in the first row. This is very light-weight and is perfect when all your query asks for is one
item. This would be excellent for receiving a count of records (Select Count(*)) in an sql
statement, or for any query where only one specific field in one column is required.
ExecuteNonQuery - This method returns no data at all. It is used majorly with Inserts and
Updates of tables. It is used for execution of DML commands.
Example:
SqlCommand cmd = new SqlCommand("Insert Into t_SomeTable Values('1','2')",con);
//note that con is the connection object
con.Open();
cmd.ExecuteNonQuery(); //The SQL Insert Statement gets executed
ExecuteReader - This method returns a DataReader which is filled with the data that is
retrieved using the command object. This is known as a forward-only retrieval of records. It
uses our SQL statement to read through the table from the first to the last record.