Beruflich Dokumente
Kultur Dokumente
What is serialization?
There are two separate mechanisms provided by the .NET class library -
XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer
for Web Services, and uses SoapFormatter/BinaryFormatter for Remoting. Both
are available for use in your own code.
1
How does .NET Remoting work?
.NET Remoting involves sending messages along channels. Two of the standard
channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used
for LANs or WANs (internet).
2
What will happen if we build an application in Debug and Release?
The Debug configuration of your program is compiled with full symbolic debug
information and no optimization. (Optimization complicates debugging, since
the relationship between source code and generated instructions is more
complex.)
What is Tracing?
The Trace class allows you to instrument your application. You can receive
informative messages from your running application that can help diagnose
problems or analyze performance. The following is an overall view of the major
steps typically involved in using tracing to analyze and correct potential
problems in deployed applications.
You can use the properties and methods in the Trace class to instrument
release builds. Instrumentation allows you to monitor the health of your
application running in real-life settings. Tracing helps you isolate problems and
fix them without disturbing a running system.
The process of obtaining information about assemblies and the types defined
within them, and creating, invoking, and accessing type instances at run time.
The .NET Framework ships with a number of different runtime hosts, including
the hosts listed in the following table.
3
Runtime Host Description
ASP.NET Loads the runtime into the process that
is to handle the Web request. ASP.NET
also creates an application domain for
each Web application that will run on a
Web server.
Microsoft Internet Explorer Creates application domains in which to
run managed controls. The .NET
Framework supports the download and
execution of browser-based controls.
The runtime interfaces with the
extensibility mechanism of Microsoft
Internet Explorer through a mime filter
to create application domains in which
to run the managed controls. By default,
one application domain is created for
each Web site.
Shell executables Invokes runtime hosting code to transfer
control to the runtime each time an
executable is launched from the shell.
What is application domain (AppDomain)
An ASP.NET page can run significantly faster than an equivalent ASP page
because an ASP.NET page runs as compiled code. Conversely, the Web server
must interpret each ASP page. However, simply upgrading a page from ASP to
ASP.NET does not guarantee improved performance.
Code in an ASP.NET page does not call COM components directly. Instead,
the .NET Framework creates a runtime callable wrapper (RCW) that serves as a
proxy between the managed code in the ASP.NET page and the unmanaged
code in the COM component. Because of the overhead from the wrapper
converting every piece of data that passes through it, an ASP.NET page that
uses COM objects is likely to have poorer performance than an equivalent ASP
page.
4
component. You can also use an equivalent .NET component instead of the COM
component. The first approach is easier to do, while the second approach
provides better performance.
You can also use the .NET Framework to create dynamic assemblies, which are
run directly from memory and are not saved to disk before execution. You can
save dynamic assemblies to disk after they have executed.
The assembly's manifest contains assembly metadata that is used for resolving
types and satisfying resource requests. It specifies the types and resources that
are exposed outside the assembly. The manifest also enumerates other
assemblies on which it depends.
5
The ASP.NET page framework provides a technique called event bubbling that
allows a child control to propagate events up its containment hierarchy. Event
bubbling enables events to be raised from a more convenient location in the
controls hierarchy and allows event handlers to be attached to the original
control as well as to the control that exposes the bubbled event.
Use the Repeater control to create a basic templated data-bound list. The
Repeater control has no built-in layout or styles; you must explicitly declare all
HTML layout, formatting, and style tags within the control's templates.
The Repeater control is different from other data list controls in that it allows
you to place HTML fragments in its templates. This allows you to create a
complex HTML structure, such as a table. For example, to create a list within an
HTML table, start the table by placing the <table> tag in the
HeaderTemplate. Next, create the rows and columns of the table by placing
<tr> tags, <td> tags, and data-bound items in the ItemTemplate. If you want
a different appearance for alternating items in the table, create an
AlternatingItemTemplate with the same contents as the ItemTemplate,
except with a different style specified. Finally, complete the table by placing the
</table> tag in the FooterTemplate.
Note The DataList control differs from the Repeater control by supporting
directional rendering (by use of the RepeatColumns and RepeatDirection
properties) and the option to render within an HTML table.
After all items have been created for the rows in the DataSource, the Footer
is added to the control (but not to the Items collection). Finally, the control
raises the ItemCreated event for each item, including the header, footer, and
separators. Unlike most collections, the Items collection does not expose Add
6
or Remove methods. However, you can modify the contents within an item by
providing a handler for the ItemCreated event.
Text is not HTML encoded before it is displayed in the DataList control. This
makes it possible to imbed script within HTML tags in the text. If the values for
the control come from user input, be sure to validate the values to prevent
security vulnerabilities.
Some mobile devices do not support cookies, so developers must find alternate
techniques for scenarios that require persistent state. For example, if a user
logs on to a page, the application could assign the developer a logon ID that is
used for the remainder of the session. Typically, you use a cookie for this form
of authentication, which is called cookie-based authentication. However, cookie-
based authentication is not an option for devices that do not support cookies.
Instead, the developer must rely on another state management mechanism.
Required Parameter:
• Compile-time errors
These errors are usually in the syntax of the code and stop the ASP from
compiling. You may have experienced this if you left the closing ”Next”
statement off of a “For” loop.
• Runtime errors
These happen when you try to execute the ASP page. For example, if you
try setting a variable outside its allowed range.
7
• Logic errors
Logic errors are harder to detect. The problem lies within the structure of
the code, and the computer cannot detect an error. These types require
thorough testing before rolling out the application.
The Debug.Write call won’t be compiled when the DEBUG symbol is not defined
(when doing a release build). Trace.Write calls will be compiled.
Trace.Write is for when you want it in release build as well. And in any case,
you should use something like log4net because that is both faster and better
“Process is unit of allocation while Thread is unit of execution. Each process has
one or more threads. Each thread belong to one process”
One can say Dataset as a Temporary Database for each client, filtered by that
client on the server working on a disconnected architecture. Where as
Datareader is similar to a Recordset of VB 6.0 or Classical ASP with
Forwardonly cursor.
While working with Dataset Connection is closed where as in Datareader
Connection is maintained.
DataReaader is connected object and one can process the rows that are
returned by query, one at a time. It discards every row after you have gone
through it and so it is extremely fast.It contains only read-only data, so no
updates are allowed using DataReader objects. In DataReader you can not get
the no. of records directly from RecordSet.This is similar to VB 6, ForwardOnly
RecordSet. Meanwhile DataSet is disconnected object type.It is slow as
compare to DataReader but you can do every type of operation by using this.
8
Object Used For
Server Accessing the server resources
1. ASP .NET Server Controls can however detect the target browser's
capabilities and render themselves accordingly. No issues for compatibility
issues of Browsers i.e page that might be used by both HTML 3.2 and HTML 4.0
browsers code to be written by you.
2. Newer set of controls that can be used in the same manner as any HTMl
control like Calender controls. (No need of Activex Control for doing this which
would then bring up issues of Browser compatibility).
3. Processing would be done at the server side. In built functionality to check for
few values(with Validation controls) so no need to choose between scripting
language which would be incompatible with few browsers.
4. ASP .NET Server Controls have an object model different from the traditional
HTML and even provide a set of properties and methods that can change the
outlook and behavior of the controls.
5. ASP .NET Server Controls have higher level of abstraction. An output of an
ASP .NET server control can be the result of many HTML tags that combine
together to produce that control and its events.
Disadvantages:
1. The control of the code is inbuilt with the web server controls so you have no
much of direct control on these controls
2. Migration of ASP to any ASP.NET application is difficult. Its equivalent to
rewriting your new application
1. The HTML Server Controls follow the HTML-centric object model. Model
similar to HTML
2. Here the controls can be made to interact with Client side
scripting. Processing would be done at client as well as server depending on
your code.
3. Migration of the ASP project thought not very easy can be done by giving
each intrinsic HTML control a runat = server to make it HTML Server side
control.
4. The HTML Server Controls have no mechanism of identifying the capabilities
of the client browser accessing the current page.
9
5. A HTML Server Control has similar abstraction with its corresponding HTML
tag and offers no abstraction.
Disadvantages:
1. You would need to code for the browser compatibility.
Disadvantages:
1. You would need to code for the browser compatibility
Code in Visual C#
10
type system, limiting the
number of objects that can be rich type system
serialized.
Web services support
.NET remoting requires the client
interoperability across
Interoperability be built using .NET, enforcing
platforms, and are ideal for
homogenous environment.
heterogeneous environments.
Can also take advantage of IIS for
Highly reliable due to the fact fault isolation. If IIS is not used,
Reliability that Web services are always application needs to provide
hosted in IIS plumbing for ensuring the
reliability of the application.
Provides extensibility by
Very extensible by allowing us to
allowing us to intercept the
customize the different
Extensibility SOAP messages during the
components of the .NET remoting
serialization and
framework.
deserialization stages.
Ease-of-
Easy-to-create and deploy. Complex to program.
Programming
What is an Authentication?
Types of Authentications?
Authentication: Basic and Digest Authentication .To use basic and digest
authentication, an application must provide a user name and password in the
Credentials property of the WebRequest object that it uses to request data from
the Internet,
11
• Remote data between tiers or from an XML Web service.
• Interact with data dynamically such as binding to a Windows Forms
control or combining and relating data from multiple sources.
• Cache data locally in your application.
• Provide a hierarchical XML view of relational data and use tools like an
XSL Transformation or an XML Path Language (XPath) Query on your data.
Perform extensive processing on data without requiring an open
connection to the data source, which frees the connection to be used by
other clients.
If you do not require the functionality provided by the DataSet, you can
improve the performance of your application by using the DataReader to
return your data in a forward-only read-only fashion. Although the
DataAdapter uses the DataReader to fill the contents of a DataSet, by using
the DataReader you can receive performance gains because you will save
memory that would be consumed by the DataSet, as well as saving the
processing required to create and fill the contents of the DataSet.
The design of the DataSet enables you to easily transport data to clients over
the Web using XML Web services, as well as allowing you to marshal data
between .NET components using .NET Remoting services. You can also remote a
strongly typed DataSet in this fashion. For an overview of XML Web services.
For an example of consuming a DataSet from an XML Web service, see
Consuming a DataSet from an XML Web Service.
DataTable objects can also be used with remoting services, but cannot be
transported via an XML Web service.
The ADO.NET components have been designed to factor data access from data
manipulation. There are two central components of ADO.NET that accomplish
this: the DataSet, and the .NET Framework data provider, which is a set of
components including the Connection, Command, DataReader, and
DataAdapter objects.
12
The other core element of the ADO.NET architecture is the .NET Framework
data provider, whose components are explicitly designed for data manipulation
and fast, forward-only, read-only access to data. The Connection object
provides connectivity to a data source. The Command object enables access to
database commands to return data, modify data, run stored procedures, and
send or retrieve parameter information. The DataReader provides a high-
performance stream of data from the data source. Finally, the DataAdapter
provides the bridge between the DataSet object and the data source. The
DataAdapter uses Command objects to execute SQL commands at the data
source to both load the DataSet with data, and reconcile changes made to the
data in the DataSet back to the data source.
You can write .NET Framework data providers for any data source. The .NET
Framework ships with two .NET Framework data providers: the .NET Framework
Data Provider for SQL Server and the .NET Framework Data Provider for OLE DB.
What is an indexer?
Defining an indexer allows you to create classes that act like "virtual arrays."
Instances of that class can be accessed using the [] array access operator.
Defining an indexer in C# is similar to defining operator [] in C++, but is
considerably more flexible. For classes that encapsulate array- or collection-like
functionality, using an indexer allows the users of that class to use the array
syntax to access the class.
For example, suppose you want to define a class that makes a file appear as an
array of bytes. If the file were very large, it would be impractical to read the
entire file into memory, especially if you only wanted to read or change a few
bytes. By defining a FileByteArray class, you could make the file appear similar to
an array of bytes, but actually do file input and output when a byte was read or
written.
13
What is an abstract Class in C# and VB.net ?
Abstract classes are closely related to interfaces. They are classes that cannot
be instantiated, and are frequently either partially implemented, or not at all
implemented. One key difference between abstract classes and interfaces is
that a class may implement an unlimited number of interfaces, but may inherit
from only one abstract (or any other kind of) class. A class that is derived from
an abstract class may still implement interfaces. Abstract classes are useful
when creating components because they allow you specify an invariant level of
functionality in some methods, but leave the implementation of other methods
until a specific implementation of that class is needed. They also version well,
because if additional functionality is needed in derived classes, it can be added
to the base class without breaking code.
14
that an inherited class may also implement interfaces — the techniques
are not mutually exclusive.
• Polymorphism through abstract classes - Abstract classes provide
elements of both inheritance and interfaces. An abstract class is a class
that cannot be instantiated itself; it must be inherited. Some or all
members of the class might be unimplemented, and it is up to the
inheriting class to provide that implementation. Members that are
implemented might still be overridden, and the inheriting class can still
implement addition interfaces or other functionality.
Any time that you add controls to a page dynamically, you have the problem of
persistence. Dynamically-added controls (or in this case, columns) are not
automatically added to the page's view state, so you are obliged to add logic to
the page to make sure the columns are available with each round trip.
You can hide and show columns if you know in advance what columns you
need. Sometimes, however, you do not know that until run time. In that case,
you can create columns dynamically and add them to the grid. To do so, you
create an instance of one of the column classes supported by the grid —
BoundColumn, EditCommandColumn, ButtonColumn, or
HyperlinkColumn. (You can add template columns to the grid, but it is slightly
more complex. Set the column's properties, and then add it to the grid's
Columns collection.
The conversion of a value type instance to an object, which implies that the
instance will carry full type information at run time and will be allocated in the
heap. The Microsoft intermediate language (MSIL) instruction set's box
instruction converts a value type to an object by making a copy of the value
type and embedding it in a newly allocated object.
15
COM callable wrapper (CCW) : A proxy object generated by the common
language runtime so that existing COM applications can use managed classes,
including .NET Framework classes, transparently.
What is Context?
What are the Web Custom Controls and Web User Controls ?
What is a Delegate?
The process of transitively tracing through all pointers to actively used objects
in order to locate all objects that can be referenced, and then arranging to
reuse any heap memory that was not found during this trace. The common
16
language runtime garbage collector also compacts the memory that is in use to
reduce the working space needed for the heap.
What is JIT?
An acronym for "just-in-time," a phrase that describes an action that is taken
only when it becomes necessary, such as just-in-time compilation or just-in-time
object activation.
17
ViewState :The current property settings of an ASP.NET page and those of
any ASP.NET server controls contained within the page. ASP.NET can detect
when a form is requested for the first time versus when the form is posted (sent
to the server), which allows you to program accordingly.
Private ViewState : State information that is written as a hidden field, such
as the form
that is currently active or the pagination information for a form
The ability to install and use multiple versions of an assembly in isolation at the
same time. Side-by-side execution can apply to applications and components as
well as to the .NET Framework. Allowing assemblies to coexist and to execute
simultaneously on the same computer is essential to support robust versioning
in the common language runtime.
A name that consists of an assembly's identity — its simple text name, version
number, and culture information (if provided) — strengthened by a public key
and a digital signature generated over the assembly. Because the assembly
manifest contains file hashes for all the files that constitute the assembly
implementation, it is sufficient to generate the digital signature over just the
one file in the assembly that contains the assembly manifest. Assemblies with
the same strong name are expected to be identical.
A typed Data Set is a class that derives from a Dataset. As such, it inherits all
the methods, events, and properties of a Dataset. Additionally, a typed
DataSet provides strongly typed methods, events, and properties. This means
you can access tables and columns by name, instead of using collection-based
methods. Aside from the improved readability of the code, a typed DataSet
also allows the Visual Studio .NET code editor to automatically complete lines as
you type. Additionally, the strongly typed DataSet provides access to values as
the correct type at compile time. With a strongly typed DataSet, type
mismatch errors are caught when the code is compiled rather than at run time.
18
An untyped dataset, in contrast, has no corresponding built-in schema. As in a
typed dataset, an untyped dataset contains tables, columns, and so on — but
those are exposed only as collections. (However, after manually creating the
tables and other data elements in an untyped dataset, you can export the
dataset's structure as a schema using the dataset's WriteXmlSchema method.)
No, we can allow using only one dataReader at once, if at all if we want to use
another dataReader then we must close first dataReader and the open and use
the Second dataReader in our application.
We have 100 WebPages in our project, in that you have to allow users
in only 20 WebPages. How will you achieve this?
We can achieve this by modifying the web.config file. In order to achieve it,
place all 20 WebPages which you want to show in a folder and give that folder
path in the web.config.
It’s a delegate that points to and eventually fires off several methods.
19
The tracing dumps can be quite verbose and for some applications that are
constantly running you run the risk of overloading the machine and the hard
drive there. Five levels range from None to Verbose, allowing to fine-tune the
tracing activities.
Multiple processes must agree that they will share the same connection, where
every parameter is the same, including the security settings
You can initialize readonly variables to some runtime values. Let’s say your
program uses current date and time as one of the values that won’t change.
This way you declare public readonly string DateT = new DateTime().ToString().
In the system.web section of web.config, you should locate the httpmodule tag
and you simply disable session by doing a remove tag with attribute name set
to session.
<httpModules>
<remove name="Session” />
</httpModules>
20
What is main difference between Global.asax and Web.Config?
ASP.NET uses the Global.asax to establish any global objects that your Web
application uses. The .asax extension denotes an application file rather than
.aspx for a page file. Each ASP.NET application can contain at most one
Global.asax file. The file is compiled on the first page hit to your Web
application. ASP.NET is also configured so that any attempts to browse to the
Global.asax page directly are rejected. However, you can specify application-
wide settings in the Web.Config file. The Web.Config is an XML-formatted text
file that resides in the Web site’s root directory. Through Web.Config you can
specify settings like custom 404 error pages, authentication and authorization
settings for the Web site, compilation options for the ASP.NET Web pages, if
tracing should be enabled, etc
Explain the sequence of events that will occur in ASP.Net page Life
Cycle?
21
IPostBackData
Handler is
implemented)
Handle Handle the client-side event that caused the RaisePostBack
postback postback and raise appropriate events on the Event method
events server.
Note Only controls that process postback (if
events participate in this phase. IPostBackEven
tHandler is
implemented)
Prerender Perform any updates before the output is PreRender
rendered. Any changes made to the state of the event
control in the prerender phase can be saved,
while changes made in the rendering phase are (OnPreRender
lost. method)
Save state The ViewState property of a control is SaveViewStat
automatically persisted to a string object after e method
this stage. This string object is sent to the client
and back as a hidden variable. For improving
efficiency, a control can override the
SaveViewState method to modify the
ViewState property.
Render Generate output to be rendered to the client. Render method
Dispose Perform any final cleanup before the control is Dispose
torn down. References to expensive resources method
such as database connections must be released
in this phase.
Unload Perform any final cleanup before the control is UnLoad event
torn down. Control authors generally perform (On UnLoad
cleanup in Dispose and do not handle this event. method)
What are “Attributes”? How many are there? Explain few of them?
22
An attribute is an object that represents data you want to associate with an
element in your program. The element to which you attach an attribute is
referred to as the target of that attribute
23