You are on page 1of 41

c

c ccc 

  c c c   c c c   c

Forms authentication can be easily implemented using login controls without writing any code.

Login control performs functions like prompting for user credentials, validating them and issuing
authentication just as the FormsAuthentication class.

However, all that·s needs to be done is to drag and drop the use control from the tool box to have
these checks performed implicitly.

The FormsAuthentication class is used in the background for the authentication ticket and ASP.NET
membership is used to validate the user credentials.

½c cc 

  c c cc ccc

 c 

   Classic ASP is Interpreted. ASP.NET is Compiled. If code is changed, ASP.NET


recompiles, otherwise does'nt.
G c 

   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.

!c ccc 

  c c"Gc c"Gcc

The old "G (ActiveX Data Object) has evolved to ADO.NET in the .NET Framework. The ADO.NET
object is a lightweight object. The ADO    was a huge object in ADO. It provided the ability to
support multiple types of cursors. It provided fast lightweight #
 # 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.
"G breaks the functionality of the ADO object to multiple classes, thereby allowing a focused
approach to developing code. The ADO.NET "   is equivalent to the "firehose" cursor. The
DataSet is a disconnected cache with tracking and control binding functionality. The " $
provides the ability to completely customize how the central data store is updated with the changes
to a DataSet.

%c cc  c  c cc


Fragment caching refers to the caching of individual user controls within a Web Form.

Each user control can have independent cache durations and implementations of how the caching
behavior is to be applied.

Fragment caching is useful when you need to cache only a subset of a page.

Navigation bars, header, and footers are good candidates for fragment caching.

*c cc$ c c c c

When there is a need to keep the business logic separate from the User Interface or when there is
some class which is big enough to have multiple number of developers implement the methods in it,
the class can be separated and written in different files as partial class.

The keyword partial must appear in each class.

//syntax for C#

Public partial class MyPartialClass1

//code

// this code could be in file1

a)c Public partial class MyPartialClass1


b)c {
c)c //code
d)c }
e)c // this code could be in file2

-c &$ ccc$cc' (  c


c c$c$cc$&c$c

Consider the following URL:

http:// localhost/form.aspx?param1=career&param2=ride
This html addresses use QueryString property to pass values between pages.

From the URL above the information obtained is:

form.aspx: which is the destination page for your browser.


Param1 is the first parameter, the value of which is set to career
Param2 is the first parameter, the value of which is set to ride

The ¶?· marks the beginning of the QueryString


¶&· is used as a separator between parameters.

private void formButtonSubmit_Click(object sender, System.EventArgs e)


{
Response.Redirect("form.aspx?Param1=" +
this.formTextfieldParam1.Text + "&Param2=" +
this. formTextfieldParam2.Text);
}

The above code is a submit button event handler and it sends the values of the query string to the
second page.

The following code demonstrates how to retrieve these valus on the second page:
private void Page_Load(object sender, System.EventArgs e)
{
this.form2TextField1.Text=Request.QueryString["Param1"];
this.form2TextField2.Text=Request.QueryString["Param2"];
}

You can also use the following method to retrieve the parameters in the string:

for (int i =0;i < Request.QueryString.Count;i++)


{
Response.Write(Request.QueryString[i]);
}

‰c ccc)c

If a site happens to not maintain a ViewState, then if a user has entered some information in a large
form with many input fields and the page is refreshes, then the values filled up in the form are lost.

The same situation can also occur on submitting the form. If the validations return an error, the user
has to refill the form.

Thus, submitting a form clears up all form values as the site does not maintain any state called
ViewState.

In ASP .NET, the ViewState of a form is maintained with a built-in state management technique keeps
the state of the controls during subsequent postbacks by a particular user.
The ViewState indicates the status of the page when submitted to the server. The status is defined
through a hidden field placed on each page with a <form runat="server"> control.
<input type="hidden" name="__VIEWSTATE" value="CareerRide">

The ViewState option can be disabled by including the directive <%@ Page
EnableViewState="false"%> at the top of an .aspx page

If a ViewState of a certain control has to be disabled, then set EnableViewState="false".

±c cc)c&$ cc 


c c c

Viewstate is used to maintain or retain values on postback. It helps in preserving a page. Viewstate is
internally maintained as a hidden field in encrypted form along with a key.

 *  c

Mc No server resources.
Mc Viewstate ensures security because it stores the data in encrypted format.
Mc Viewstate are simple. They are used by enabling or disabling the viewstate properties.
Mc It is based on the wish of developer that they want to implement it at the page level
or at control level.

" * 

a)c If large amount of data is stored on the page, then page load might cause a problem.
b)c Does not track across pages. Viewstate information does not automatically transfer from
page to page.

ßc "

  c c c c +, c

With the ¶src· attribute, the source code files are deployed and are compiled by the JIT as needed.
Though the code is available to everyone with an access to the server (NOT anyone on the web), this
method is preferred as it does away with the compilation of the DLLs.

¶CodeBehind· attribute just has the VS.NET associate the code file with the aspx file. This is necessary
since VS.NET automates the pre-compiling that is harder by hand.

Due to this the ¶Src· attribute is done away with having only a DLL to be deployed enhancing the
protection level even though it can be decompiled.

-c ccc 

  c c. c c. c


A URL (Uniform Resource Locator) is the address of some resource on the Web. A resource is nothing
but a page of a site. There are other type of resources than Web pages, but that's the easiest
conceptually.

A URI is a unique identifier to usually a namespace. Though it looks like a URL but it doesn·t have to
necessarily locate any resource on the web. URI is a generic term. URL is a type of URI.

c c+cccc 

  c c. c c. cc

. c- Uniform Resource Identifier: it·s a string and its responsibility is to identify a resource by meta-
information. It gives information about only one resource.

.  - Uniform Resource Locator: identifies the resource on the net and tells it is obtainable using
what protocols.

½c ccc +$ c


 c
cc½-c

Previously, in ASP.NET, the pages and the code used to be compiled dynamically and then cached so
as to make the requests to access the page extremely efficient. In ASP.NET 2.0, the pre-compilation
feature is used with which an entire site is precompiled before it is made available to users.

There is a pre-defined folder structure for enabling the pre-compilation feature:

App_Code: stores classes

App_Themes: stores CSS files, Images, etc.

App_Data: stores XML files, Text Files, etc.

App_GlobalResources: stores all the resources at global level E.g. resx files, etc

App_LocalResources: stores all the resources at local/Page level

!c c+cccc +$ c


 c
cc½-cc

It is a process where things that can be handled before compilation are prepared in order to reduce
the deployment time, response time, increase safety. It·s main aim to boost performance.

It also helps in informing about the compilation failures.

During development, it allows you to make changes to the web pages and reuse it using the same
web browser to validate the changes without compiling the entire website.

During deployment, it generates the entire website folder structure in the destination. All the static
files are copied to the folder and bin directory would later on contain the compiled dll.

%c c  cc c c   c cc


Custom controls are user defined controls. They can be created by grouping existing controls, by
deriving the control from System.Web.UI.WebControls.WebControl or by enhancing the functionality
of any other custom control. Custom controls are complied into DLL·s and thus can be referenced by
as any other web server control.

Basic steps to create a Custom control:

Create Control Library

Write the appropriate code

Compile the control library

Copy to the DLL of the control library to the project where this control needs to be used

The custom control can then be registered on the webpage as any user control through the
@Register tag.

*c cc c$$  c  c

It's a way in CLR to maintain a boundary between various applications to ensure that they do not
interfere in working of any other application. CLR acts as a mini operating system where a single
process may have various application domains.

-c &$ cc  $c


c$$  c  c

An operating system process can have many ongoing application domains. Application Domains keep
an application separate. All objects created within the same application scope are created within the
same application domain. Multiple application domains can exist in a single operating system process.
Distinct memory address space allocation by the OS is effective but expensive and it does not satisfy
to the numbers required for large web servers. However, the CLR isolates an application by managing
the memory use of code running within the application domain due to which the code cannot access
memory outside the boundaries of the domain.

‰c &$ ccc 

  c($c
c c c  c c cc

Ways in which object can be created using Remoting: -

Gc  * c  * c G c / c  0 lasts the lifetime of the server. They are activated as
SingleCall/Singleton objects. It makes objects stateless. A SingleCall object gets created for each
request by client and a Singleton object is created once on the server and is shared by all the clients.

Gc/ c * cG 0 CAO creates stateful objects. The object creation request is based
on the request by client side. Therefore, the lifetime is based on client and not server. Single instance
of object is created for every call.
±c " cGc   c
c  c

Remoting has at least three sections:-

1.c Server
2.c Client: This connects to the hosted remoting object
3.c Common Interface between client and the server .i.e. the channel

Remoting takes an indirect approach to application domain communication by creating proxy


objects. Communication is performed as below:

a)c When a client object wants to create an instance of the server object, the remoting
system at the client creates a proxy of the server object. The proxy object is at the client
but behaves exactly like the remote object i.e. the server object.
b)c The proxy passes the call information to the remoting system on the client. Client
remoting system then sends the information to the remoting system on the server which
then invokes the actual method on the server object. The remoting system on the server
then passes the result information back to the client remoting system.
c)c The client remoting system returns the results to the client object through the proxy.

ßc &$ c  c   c


c  c

Singleton architecture is to be used when all the applications have to use or share same data.

½-c "
 c1c$  $1c  G c c c

Terms related to lifecycle of a remoting object.

The LeaseTime property protects the object so that the garbage collector does not destroy it as
remoting objects are beyond the scope of the garbage collector. Every object created has a default
leasetime for which it will be activated. Once the leasetime expires, the object is eligible again for
garbage collector and is eventually destroyed. Default value is 5 minutes.

Even though the leasetime of an object has expired, there still may be clients who would still need the
remoting object on the server. In such cases the leasemanager keeps a track of such clients and asks
them if they need the object and are ready to extend or sponsor the object to extend its existence.
This is done through SponsorshipTime property, which is then based on the sponsor.

The RenewOnCallTime property defines the duration for which a remoting object's lease is extended if
a sponsor is found. The default value is 2 minutes.

The LeaseManager class has a property PollTime, which defines the frequency at which the
LeaseManager polls the leases. Default is 10 seconds.

½ c , 
(c&$ ccc$ 
(c  c$  c c 
c
c

The remoting parameters can be specified through both programming and in config files. All the
settings defined in config files are placed under <system.runtime.remoting>
<application> is placed under system.runtime.remoting but the name attribute of application tag
specifies if the parameter is for server or client. RemotingConfiguration.Configure is used to access
the configuration keys for remoting properties.

½½c cc  c&$ c($c


c  c

Marshaling is a process of transforming or serializing data from one application domain and
exporting it to another application domain.

½!c c($c
c  cc

ë   
a copy of an object is created by the server and is passed and used by the client.

ë  



: the client creates a proxy to access the object.

½%c ccG 
c c c  c

ObjRef is a searializable object returned by Marshal() that knows about location of the remote object,
host name, port number, and object name.

½*c &$ cc$c


c '  cc$ &(c c cc * c
c
Mc Client communicates to UDI node to retrieve a list of available web services that the client has
access to.
Mc Every service listed has a URI pointing to the service's DISCO or WSDL document, which is
needed to access the webservice and its 'webmethod" methods.
Mc After interpreting the DISCO document, follow the URI for the WSDL document related to the
chosen webservice.
Mc Client then adds and parses the WSDL document and creates a proxy object which can then
communicate with Webservice and access its "webmethod" methods.

½-c &$ cc$cc ccc * c c  cc

Steps to create and consume a webservice

  c

a. Create a new website by selecting "ASP.NET Web Site" and giving it a suitable name.

b. service.cs file appears inside the solution with a default webmethod named as "HelloWorld()"

c. Right click on the webservice project and add a web reference instead of adding a normal
reference.

d. A window appears that displays a list of webservices knows to the solution.

e. Click on "Webservices in this solution"


f. a search progress bar appears and

g. Select the service that appears in the list

h. progress bar appears once again.

i. web method appears on the screen

j. Click on "Add reference" button. This would add localhost

k. solution would have App_WebReference folder

 $ c c.

a. Add a UI (.aspx) to the webservice project

b. Add a button and a label to the form

c. Double click the button to see the click event of the button

d. Create an object of type service localhost.serviceName

e. Write code to display the value returned by the webmethod on the label

f. Execute the solution by setting the added aspx as the startpage.

g. click on the button and the message "Hello World" would be displayed on the label

$$  c G  Application variable/object stores an Object with a scope of availability of the
entire Application unless explicitly destroyed.

  cG  The lifetime of cache is throughout the lifetime of an application or is based upon
timeouts

½‰c cc c 2c c c

The cache object has dependencies e.g. relationships to the file it stores. Cache items remove the
object when these dependencies change. As a work around we would need to simply execute a
callback method whenever items are removed from the cache to add the items back in cache.

e.g.: We have a string variable string var="hello" and store it in cache. This item would be
removed from the cache if value is changed from "hello" to "bye". In such a case we need to
simply right a callback function which would add updated var back in cache as it·s been
removed as a result of its dependencies changing.
½±c cc *  c

A process where items are removed from cache in order to free the memory based on their priority. A
property called "CacheItemPriority" is used to figure out the priority of each item inside the cache.
This priority property is set when an item is added to the cache.

½ßc &$ cc($c


c  c c c c
cc

c$ Is used to fetch information or data at page level. It is best used when the site is mainly
static. Used by declaring the output page directive

c
  Is used to cache the structure level information. It is used when parts of pages
change. For example: user control

   c  c  Is used to fetch the information of an application quickly based on the
requirements.

!-c cc c&$ccc c 

  c*  c
cc$c cc c
 c

The ways to cache different versions on the same page using ASP.NET cache object is using
OutputCache object.

Three parameters of OutputCache, has 3 parameters:

) ,(  based on input parameters passed through HTTP POST/GET.

) ,(  based on the page header content.

)(,( based on declaration of an attribute and overriding GetVaryByCustomString handler.

) ,(   varies with the value of properties of ASP objects.

! c &$ ccc$ c  c c

Fragment cache is to store user controls individually within a web form in cache instead of the whole
webform as such. The idea is to simply have different cache parameters for different user controls.

control1: <%@ OutputCache Duration="40" VaryByParam="none"%>

control2: <%@ OutputCache Duration="60" VaryByParam="none"%>


If control1 and control2 exist on a single webform together, the values of control1 and control2 would
be cached for different durations based on @OutputCache directive.

!½c &$ cc* c c


c  cc c

Types of sessions:

InProc: The default way to use sessions. InProc is the fastest way to store and access sessions.

OutProc:
i. State server: 15% slower than InProc. Session is serialized and stored in aspnet_state.exe process.
Stateserver sessions can be stored on a separate machine too.
ii. SQL Server: 25% slower than InProc. Used when data is to be serialized and stored in SQL Server
database.

!!c c cc 

  c($c
c cc  c$ c*ccc

 +  cc  

The In-Process type of Session state management stores the session in memory on the web server.

In order to have a user always reconnect to the same web-server, a sticky server is needed.

G+
+  cc  

Out-of-Process Session state management stores data in an external data source.

The external data source may be a SQL Server or a State Server service.

Out-of-Process state management requires the objects in a session to be serializable..

!%c c cc 


c c c
c c  c
 c
0c  *  c
a.c Easy to implement
b.c Hidden fields are supported by all browsers
c.c Enables faster access of information because data is stored on client side
0c " *  c
a.c Not secure because the data is stored on Client side.
b.c Decreases page performance if too many hidden fields
c.c Only support single value.

!*c c cc 


c c c
c c  c c
0c  *  c
a.c Hidden frames allow you to cache more than one data field.
b.c The ability to cache and access data items stored in different hidden
forms.

0c " *  c

a.c Not supported by all browsers


b.c Stored data is not secured as it is stored on client's machine in the form
of hidden fields
!-c c c 
c c c
c c2c
0c  *  cc
a.c They are simple to use.
b.c Light in size, thus occupy less memory.
c.c Stores server information on client side
d.c Data need not to be sent back to server.
e.c Cookies persist for much longer period of time than a session.
0c " *  cc
a.c Since they are stored on the client side in plain text, they are not secure.
b.c Number of cookies that can be stored and their size is limited.
c.c They don't work if security level is set too high in browser.
d.c Some people might just disable cookies on their browsers.

!‰c cc3 (  c, 


c c c
c c' (  c

Querystring is way to transfer information from one page to another through the URL. QueryString is
attached to the URL with "?".

 *  c

a. Supported by all the browsers


b. No extra effort is needed to code.
c. Easy to use.

" *  c

All the attributes and values are visible to the end user. Therefore, they are
not secure.
b. There is a limit to URL length of 255 characters.

!±c ccc c  c&$  c cc


Absolute and sliding expiration are two Time based expiration strategies.
Absolute Expiration: Cache in this case expires at a fixed specified date or time.
Example: Cache. Insert("ABC", ds, null, DateTime.Now.AddMinutes(1), Cache.NoSlidingExpiration);
The cache is set to expire exactly two minutes after the user has retrieved the data.

Sliding Expiration: the cache duration increases in this case by the specified sliding expiration value
every time the page is requested. More a page is requested it will remain in cache, whereas a less
requested page will not remain in cache.

Example: Cache.Insert("ABC", ds, null, Cache.NoAbsoluteExpiration,


TimeSpan.FromMinutes(1));

!ßc &$ cc  $c c $c


c c$c$ c

 cc : It refers to the scenario where on event of some controls posts from one page
to another instead of a normal postback. Normal postback is when for e.g. a button (or any control
that postbacks) is clicked and web page is submits the page back to itself which means a return trip.
In Cross page posting, on click of a button there would be no return trip.

Cross-page posting is done at the control level. It is possible to create a page that posts to different
pages depending on what button the user clicks on. It is handled by done by changing the
postbackurl property of the controls.

%-c &$ ccc c)c*c


cc$c cc &c$c

PreviousPage property is set to the page property of the nest page to access the viewstate value of
the page in the next page. Page poster = this.PreviousPage;
Once that is done, a control can be found from the previous page and its state can be read.
Label posterLabel = poster.findControl("myLabel");
string lbl = posterLabel.Text;

% c cc3c c"$  (c cc

SQL Cache Dependency in ASP.NET: It is the mechanism where the cache object gets invalidated when
the related data or the related resource is modified. It is a feature in SQL Server 2005 and SQL Server
2000.

3 types of SQL-cache dependencies exist:

Other cache items.

Files/folders.

Dependencies on a database query.


%½c &$ cc  $c
cc c c cc

c  c It works opposite to fragment caching. The entire page is cached, except
what is to be kept dynamic. When [OutputCache] attribute is used, the page is cached on both the
server and the client. Whereas, you use in case of post cache substitution the page is cached on the
server only. HttpResponse.WriteSubstitution method is a way to implement it.

%!c &$ ccc


c 4 c c54 c

Users of different countries, use different languages and others settings like currency, and dates.
Therefore, applications are needed to be configurable as per the required settings based on cultures,
regions, countries.

Globalization: Is a way of writing the executables in a way that they are culture or language neutral.
The culture and language details specific details should be kept configurable. The main part of
Globalization is to find out the locale-sensitive resources that are needed to be kept configurable and
to segregate these resources from the executable code.

Localization: Is the task to customize the application. The main part of localization is the translation of
resources found in globalization.

%%c &$ cc  $c


cG"cc$$  cc cc  * c
cc$$  c

Code Page was used before Unicode came into existence. It was a technique to represent characters
in different languages. It was a different interpretation of ASCII set which means it kept 128 characters
for English and rest 128 were specifically tailored for other languages.

" *  c

a.c Languages like Japanese and Chinese having more than 5000 characters
were difficult to represent n 128 character set.
b.c Clients also need to have a support for code page.
c.c It¶s representation is done on the basis of operating system.
%*c c c  c
c c&$ cc cc  c  c
c

Resource files are files in XML format. They contain all the resources needed by an application. These
files can be used to store string, bitmaps, icons, fonts.

Steps to generate a resource file:

a.c Open the web page in the design view.


b.c Click Tools
c.c Select generate local resource
d.c .resx file generated in the solution explorer
e.c Type in the resources. The file contains the key and value pairs.
f.c Save the file.
%-c c ccc ccc  ccc
To support the feature of multiple languages, we need to create different modules that are
customized on the basis of localization. These assemblies created on the basis of different modules
are knows as satellite assemblies.

Steps to generate satellite assemblies:

a)c Set the paths for resgen and al.exe:


b)c Create a .resources file.
c)c Create the satellite assembly.
d)c The assembly should have the naming convention for .NET to be able to search for it.
e)c Specify the settings for culture.
f)c Put the satellite assembly in the appropriate folder.
g)c Once the satellite assembly is created, physically copy it to the appropriate directory.
h)c Repeat the process for each language in which you are creating an assembly.
%‰c ccc(c

Satellite Assemblies are language-specific assemblies and are used for language-specific resources for
an application. Each assembly of this kind has a separate language specific ID and is installed in a
language-specific subdirectory for each language.

%±c "
 c6c c 56c

Al.exe: It embeds the resources into a satellite assembly. It takes the resources in .resources binary
format.
resgen.exe:The input for Al.exe is generally plain text or XML-based resource files i.e. in .resx format.
resgen.exe is used to convert such resources to the .resource in binary format which makes then
compatible with al.exe.

%ßc &$ cc  $c


c  c  c c

ResourceManager class: It provides convenient access to resources that are culture-correct. The access
is provided at run time.

This class provides resource withdrawal when a localized resource does not exist. It helps in resource
serialization, and provides access to resources that are not packaged in your assembly. It is very much
possible to derive classes from ResourceManager class and create our own custom resource solutions.

*-c cc c    c


  1cc

WCF is a framework that builds applications that can inter-communicate based on service oriented
architecture consuming secure and reliable web services. This also helps in Distributed computing.
The WCF also brings together the various communication models into a single model.

* c &$ cc$  c$  $c


cGc

A service-oriented architecture is collection of services which communicate with one another other.
The communication can range from simple data passing to two or more services organizing some
activity.
*½c &$ cc $  c
cc+c * c 1c c *   1c"c$ c

WCF Service is composed of three components:

 * c  It implements the service needed.

c *    is an environment that hosts the developed service.

 $  are the connection points for the clients to connect to the service. Clients find the end
points through three components like service contract, binding, and address.

*!c "

  c cc cc * c

WCF can create services similar in concept to ASMX, but has much more capabilities. WCF is much
more efficient than ASP.Net coz it is implemented on pipeline. WCF is more secure, reliable. As WCF is
implemented on a different pipeline it does not have all Http capabilities (Http session, cache etc).

*%c c c 

  c  c$$  c(cc


a)c BasicHttpBinding
b)c WSHttpBinding
c)c WSDualHttpBinding
d)c WSFederationHttpBinding
e)c NetTcpBinding
f)c NetNamedPipeBinding
g)c NetMsmqBinding
h)c NetPeerTcpBinding
i)c MsmqIntegrationBinding
**c cc $&c    c cc

Duplex contract: It enables clients and servers to communicate with each other. The calls can be
initiated independently of the other one. The duplex contract is one the message patterns available to
Windows Communication Foundation (WCF) services. It comprises of two one-way contracts.

*-c "

  c    c c*c cc

Read Uncommitted: - Also known as Dirty isolation level. It makes sure that corrupt Data cannot be
read. This is the lowest isolation level

Read Committed: - It ensures not to read the data that has been changed by any other application
and is not yet committed. It is the default level.

Repeatable Read: - It stops the usage of dirt read and non-repeatable read. It states that data fetched
through a query will be locked and will not be updated by any other transaction.
Serializable: - It does not allow any modification and addition of new data till the transaction is
completed. This is considered to be a very restrictive level.

Snapshot: - It raises error on modifying a data that has already been changed by any transaction.

*‰c c c)c c" c c'c

)c3 There are scenarios in the project when you want the message to deliver in proper
time. The timely delivery of message is very more important and to ensure they are not lost is
important too. Volatile queues are used for such purposes.

" + c 3 Queues are needed so that client and server are not required to run at the
same time when the message is sent. When a message lies inside a queue for a long time on the
server and becomes invalid after some time period, then such messages are not to be sent to the
client. All these messages are sent to dead-letter queue. Therefore, dead-letter queues are
responsible for storing messages that fail timely delivery.

*±c cc c 2


c
  c

 c  2
c   c /0 c It is a platform for building, managing and executing
workflow-enabled applications, for designing and implementing a programming model for
controlling and communicating with workflows, a workflow execution engine and more.

*ßc &$ cc($c


c 2
c c c 2
c  c

There are 3 types of workflows in WWF:

' c 2
 The sequential workflow style executes a set of contained activities in order,
one by one and does not provide an option to go back to any step.

c  c 2
 It represents the workflow in the form of a state machine containing set of
states, each of them receiving events. These events lead to transition from one state to another one.

+ * c 2


 It is based on Sequential/StateMachine workflow.

--c c c6Gc


c

XOML is an acronym for Extensible Object Markup Language. XOML files are the markup files. They
are used to declare the workflow and are then compiled with the file containing the implementation
logic. XOML file is used separately to ensure code-separation workflow authoring

- c cc2c c$$  c

 c cc½-c
Microsoft's Internet Information Services web server software is used to make an application offline.
The IIS is instructed to route all incoming requests for the web site to another URL automatically.

Steps for application configuration:

In the properties of IIS manager, choose Virtual Directory tab and indicate that the content for this
application should come from "A redirection to a URL."

Then enter the same URL to redirect.

-½c c c $c   c 2c

Script injection attacks called Cross-site scripting (XSS) attacks exploit vulnerabilities in Web page
validation by injecting client-side script code.

This code executes on the user·s browser after the browser downloads the script code from a trusted
site and then the browser has no way of determining the legitimacy code.

-!c cc   c cc

Authentication is the process of verifying user·s details and find if the user is a valid user to the system
or not. This process of authentication is needed to provide authority to the user. ASP.NET implements
authentication through authentication providers. Each provider has OnAuthenticate event. It allows
building a custom authorization scheme.

-%c cc 4 c cc

Authorization is a process that takes place based on the authentication of the user. Once
authenticated, based on user·s credentials, it is determined what rights des a user have. In ASP.NET,
there are two ways to authorize access to a given resource:

a. File authorization

b. URL authorization

-*c "
 c c 
 ccc

Access modifiers are used to control the scope of type members.


There arefive access modifiers that p rovide varying levels of access.
Public (public), Friend (internal), Private (private), Protected (protected), and Protected Friend
(protected internal).

--c cc $ c


 cc$c cccc

System.Web.UI.Page

-‰c  c 

  c c*   c c*   ccc


Overriding - Methods have the same signature as the parent class method.
Overloading - Methods have different parameters list or type or the return type.

-±c  c $ c


 c c c cccc

System.Web.UI.Page.Culture

-ßc  * c c  * c


c c   ccc

 * 

Simultaneous access to multiple applications

Reduced number of required servers

Improved performance and concurrency

Simplified coding of remote procedure calls and conversations

" * 

Code writing, debugging, managing concurrency, testing, porting existing code is difficult in
multithreading and multicontexting.

Programmers need to remove static variables and replace any code that is not thread-safe to
introduce threading into a previously non threaded application.

‰-c c c+   c 2c ccc

There are two main ways of multi-threading which .NET encourages:

To start your own threads with ThreadStart delegates, you should create a new thread "manually" for
long-running tasks.

Using the ThreadPool class either directly (using ThreadPool.QueueUserWorkItem) or indirectly using
asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).

Use the thread pool only for brief jobs.

‰ c , 
c
c cc  cccc

Benefits of using the Thread Pool.

The benefits of using a Thread Pool are:


Thread creation and destruction overhead is negated,
Better performance and better system stability.
It is better to use a thread pool in cases where the number of threads is very large.

‰½c  c


c cc  cccc

A thread pool executes on a single processor. But they are theoretically associated to server farms in
which a master process distributes tasks to worker processes on different computers to increase the
overall throughput.

However, parallel problems are highly open to this approach

‰!c &$ c c c c  c  c   c  c   c c  c c (   c
$ c cccc

using System.Threading;

private void ThreadTask()

int x;

int val;

Random r=new Random();

while(true)

x=this.progressBar1.Step*r.Next(-1,2);

val = this.progressBar1.Value + x;

if (val > this.progressBar1.Maximum)

val = this.progressBar1.Maximum;

else if (val < this.progressBar1.Minimum)

val = this.progressBar1.Minimum;
this.progressBar1.Value = val;

Thread.Sleep(100);

You need to write these lines first:

Thread t1 = new Thread(new ThreadStart(this.ThreadTask));

t1.IsBackground = true;

t1.Start();

‰%c &$ cc$ $c


c&c c cccc

System uses synchronization mechanism to make sure that a resource is used by only one thread at a
time when more than one thread needs to access a shared resource at the same time.

Mutex grants exclusive access to the shared resource to a single thread.

A second thread that needs to acquire a particular mutex is suspended until the first thread releases
the mutex.

‰*c " c c  $c 


c   c 1c c    2 c c  c c      2c
ccc

Access to objects by is controlled by the Monitor class. It grants a lock for an object to a single thread.
Critical sections can be access restricted by using object locks.
While a thread owns the lock for an object, no other thread can acquire that lock.
Interlocked class provides atomic operations for variables that are shared by multiple threads.
When two threads are executing concurrently on separate processors error protection is done.
The methods of this class help protect against errors that can occur when the scheduler switches
contexts while a thread is updating a variable that can be accessed by other threads.
ReaderWriterLock synchronizes access to a resource. It allows either concurrent read access for
multiple threads, or write access for a single thread.
A ReaderWriterLock provides better throughput than a simple one lock a time like Monitor.

‰-c &$ cc 4 c cc&$ c  (c 4 c c6c 4 ccc
System.Runtime.Serialization namespace provides Serialization in .NET.
The IFormatter interface in the namespace contains Serialize and De-serialize methods that save and
load data of a stream.
So we need stream as a container for the serialized object(s) and a formatter that serializes these
objects onto the stream to implement serialization in .net.

Binary serialization is a mechanism that creates exact binary copy of the object onto the storage
media by writing the data to the output stream such that it can be used to re-construct the object
automatically.

XML serialization results in strongly typed classes with public properties and fields that are converted
to a serial format for storage or transport. This XML stream conforms to a specific XML Schema
definition language (XSD) document.

&$ c(c 4 c

An object is stored in a file, a database or even in the memory. However, data to be transferred over a
network needs to be in a linear form for which serialization and deserialization are used.

Advantage of serialization is the ability of an object to be serialized into a persistent or a non-


persistent storage media and then reconstructing the same object later by de-serializing the object.

Remoting and Web Services depend heavily on Serialization and De-serialization.

‰‰c &$ cc $  cc $ cc  (c 4 c   c

To binary serialize an object we need a FileStream object,


Constructor: FileStream(file_name, FileMode.Create);

And

BinaryFormatter
Constructor: binaryFormatter.Serialize(fileStreamObject, object1);

‰±c cc  c&$ cc  (c


  c ccGc
  ccc

A formatter determines the serialization format for objects.

.NET framework provides Binary formatter and SOAP formatter which inherit from the IFormatter
interface

c,  (c 

It provides binary encoding for compact serialization for storage or socket-based network streams.
It is not appropriate for data to be passed through a firewall.

cGc 
It provides formatting that can be used to enable objects to be serialized using the SOAP protocol.
The class is used for serialization through firewalls or diverse systems.

‰ßc c cc c * c


c  (c 4 c

An object is stored in a file, a database or even in the memory. However, data to be transferred over a
network needs to be in a linear form for which serialization and deserialization are used.

Advantage of serialization is the ability of an object to be serialized into a persistent or a non-


persistent storage media and then reconstructing the same object later by de-serializing the object.

Also Binary Serialization is faster, supports complex objects too with read only properties and even
circular references.

±-c c c(c $cc  (c 4 c

public static void SerializeBinary( object o, string file_name)

using (FileStream fs = new FileStream(file_name, FileMode.Create)) {

BinaryFormatter fmt = new BinaryFormatter ();

fmt.Serialize(fs, o);

± c c c(c$ c   c cccc

In C#.NET, we implement using ":"

In VB.Net we implements using "Inherits" keyword.

±½c &$ cc 

  c c * + c c + c  ccc

Server-side code executes on the server.

Client-side code executes in the client's browser.

 *   
 c c $     .

Server.Transfer

Transfers page processing from one page directly to the next page.

No round-trip back to the client's browser.


Faster response with lesser overhead on the server.

Server.Transfer does not update the clients url history list or current url.

Response.Redirect

Used to redirect the user's browser to another page or site.

Performs a trip back to the client where the client's browser is redirected to the new page.

The user's browser history list is updated to reflect the new address.

±!c "
 c"Gc"ccc

A Dataset can represent an entire relational database in memory, complete with tables, relations, and
views. A dataset is designed to work without any continuing connection to the original data source.

You can use For Each loops to move through the data in the dataset.

±%c "
 c&c cccc

The Global.asax is including the Global.asax.cs file.

You can implement application and session level events using global.asax.

±*c c cc$$  7 c c 7 c  c c
 ccc

These subroutines set the variables for the Application and Session objects.

±-c "
 c  c  c c  c ccc

Inline code written along side the html in a page.

Code-behind is code written in a separate file and referenced by the .aspx page.

±‰c ccccc

MSIL is the Microsoft Intermediate Language. .NET compatible application will get converted to MSIL
on compilation. MSIL gets converted into machine language or native code by JIT compiler.

±±c cc cc c  c


ccc

The Page class

±ßc &$ c 

  c c  c *c  c +c c /c $  c 01c  c / 01c
c/ 0ccc
Low (IIS Process):

This is the fastest and the default IIS4 setting. ASP pages run in INetInfo.exe and so they are executed
in-process. If ASP crashes, IIS too does and must be restarted.

Medium (Pooled):

This IIS setting is more reliable. In this if ASP crashes, IIS does not. In this, the ASP applications share
the same process, so a web site can run with just IIS and ASP process. IIS5 supports this setting and is
the default setting.

High (Isolated):

This setting runs in MTS.EXE in IIS4 and in DLLHOST.EXE in IIS5. If one ASP application crashes, IIS or
other ASP applications don·t crash. Each ASP application runs out-process in its own space.

ß-c cc  c/ 0c ccc

It belongs to the type but not to any instance of a type.

It can be accessed without creating an instance of the type.

It can be accessed using the type name instead of the instance name.

It can't refer to any instance data.

ß c ccc  $ c$  c(ccc ccc * ccc

SOAP (Simple Object Access Protocol) is the preferred protocol.

ß½c ccG$ c  c c


 cc

Option Strict On enables type checking at design time andprevents type mismatch bugs.

ß!c " c,& c c. & cc

Boxing allows you to treat a value type the same as a reference type.

Unboxing converts a boxed reference type back to a value type.

ß%c c c"c c


 c&$ cc$ $cc

Web Services Description Language.

ß*c "
 c)c ccc
It allows the state of objects (serializable) to be stored in a hidden field on the page. It is transported
to the client and back to the server, and is not stored on the server or any other external source. It is
used to retain the state of server-side objects between postbacks.

ß-c ccc
$ c
 cc  c c)cc

Items stored in the ViewState exist for the life of the current page. This includes postbacks (to the
same page).

߉c &$ cc$ $c


c )c$ $ (ccc

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.

ß±c c c"c&$ cc c&$ ccc$ c c ccc

Delegates provide the functionality behind events. A delegate is a strongly typed function pointer.
Invoke a method without making an explicit call to that method. In Visual Basic .NET, the role of the
delegate is largely behind the scenes .

ßßc c ccc

Classes are the blueprints for objects. A class acts as a template for any number of distinct objects.

--c cc $ cc

The data of an object should never be made available to other objects.

- c c  c c 

  c ($c 
c  c c   c $ c *c c
c&$ ccc

ASP.NET provides In-Process and Out-of-Process state management.

In-Process stores the session in memory on the 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.

-½c c cc c


  c   cc$c c&$ c c
ccc

Init() - when the page is instantiated.


Load() - when the page is loaded into server memory.

PreRender() - the brief moment before the page is displayed to the user as HTML

Unload() - when page finishes loading.

-!c  $1c $c c


 c"Gcc

It is data-access technology, primarily disconnected and designed to provide efficient, scalable data
access.

The disconnected data is represented within a DataSet object.

A data provider is a set of classes that provide access to databases. The main components of data
provider are:

Connection

Command

DataReader

DataAdapter

Visual Studio .NET includes two data providers:

SQL Data Provider

OleDb Data Provider

Two additional data providers are included in Visual Studio .NET 2003:

ODBC Data Provider

Oracle Data Provider

-%c "
 c * + c c + c  c cccc

Server-side code runs on the server.

Client-side code runs on the client's browser.

-*c cc c(ccc cc($  2c  ccc"5  cc

<asp:HyperLinkColumn>
--c  c c)c cc$$  c$  cc

Web application projects create a virtual folder for each project where all the files of the projects are
stored. The virtual folder can be viewed in IIS and property of that folder determines where the files
are physically stored.

-‰c " cc$$  8c


c ( cc

A Web application starts with the first request for a resource.

On request, Web forms are instantiated and processed in the server.

Server sends its response to the client.

Application ends once all client sessions end.

-±c "
 c c c cc  c c
-ßc $cc& cc  c$    c
cc$$  cc

Create a command object.

Set the object·s CommandText property to the name of the stored procedure.

Set the CommandType property to stored Procedure.

Execute stored procedure using command object·s method.

-c " c& $ c  c cc

Exception handling correct unusual occurrences and prevent application from getting terminated. You
can use Try(try) block and Error event procedures to handle exceptions.

Exceptions or errors are unusual occurrences that happen within the logic of an application. The CLR
has provided structured way to deal with exceptions using Try/Catch block. ASP.NET also
supports exception handling through server events such as Page_Error and Application_Error events.

c c cc(c
c  c& $ c cccc
There are three ways to handle exceptions in ASP.NET
Try/catch/finally block.
Using Events like Page_Error and Application_Error
Using Custom error page

½c " cc


c  c$c cccc

Error pages are used when exceptions are outside the scope of the application and the application
can·t respond directly to these exceptions. These types of exceptions are identified by HTTP response
codes, which IIS can respond to by displaying custom error pages listed in your application·s
Web.config file.

!c &$ c   c cccc

Tracing records unusual events while an application is running. It helps in observing problems during
testing and after deployment. An application can write a message in case of unusual events to the
trace log using Trace class.

%c cccc
c)c ccc

ComVisible attribute is used to select which public .NET classes and members are visible to COM.

*c "
 c c c c   ccc

Windows authentication is the default authentication method of the ASP.NET application. It uses
security scheme of windows operating system of corporate network. Windows authentication uses
user names, passwords, and permissions of network resources and Web applications. User lists for
Windows authentication are included in the element of Web.config.
Form authentication allows creating own database of users in the application·s Web.config file or in a
separate user database and validate the identity of the users when they visit Web site. Users do not
have to be member of a domain-based network to have access to your application.

-c cc  c 2c( c/0c  (ccc

SSL protects data exchanged between a client and an ASP.NET application by encrypting the data
before it is sent across the internet.
c c

What Great .NET Developers Ought To Know

Everyone who writes code

" cc 

  c cc  c cc  ?


A process is a collection of virtual memory space, code, data and system resources. A Thread is code
sequence that is to be serially executed within a process. The processor executes the threads, not
processes, so each application has at least one process and a process always has at least one thread of
execution, called the primary thread. A process can have multiple threads in addition to the primary
thread. Prior to the introduction of the multiple threads of execution, all applications were designed to
run on a single thread of execution. When a thread begins to execute, it continues to run until it is killed
or until interrupted by a thread with higher priority (by a user action or kernel·s thread scheduler). Each
thread can run separate sections of code, or multiple threads can execute same section of code. Threads
executing same block of code maintain separate stacks. Each thread in a process shares that process·s
global variables and resources.

ccc c * c cc cc


 ( c 

 c
cc#  #c6cc

Standard EXE's are run by users that are logged onto the system. This is accomplished by either
navigating to the shortcut associated with the application (either on the programs menu or the desktop)
or clicking on the icon. This will run that application using the rights of the currently logged on user. You
can also run as another user by right-clicking on the icon and selecting run-as from the context menu, but
you get the picture. Standard EXE's are associated with the current user and their desktop.

Windows Services, on the other hand, are processes that can exist and run without a user/desktop. The
windows service runs in its own windows session without the need for any particular user to be logged
onto the system. They are initiated when the system boots up. As opposed to a Standard EXE, they have
no user interface as they run in the background of your computer by using the Computer Management
Console.

So the lifecycle of a Windows Service is different from the lifecycle of a Standard EXE because a Windows
Service is associated with the system (but can use any account) and begins its "life" when the system
boots up. A Standard EXE needs a signed on user(manually or programmaticlly)to initiate its instantiation.

c c c &c  c 


c  (c  (c  c $  c  c  c  c  c c c


  c  c c &c * c  (c


 c c (c c  c c 

 c c (c
 cc

NT-based OSs split memory into user and kernel space. The amount of memory usable is dependent on
the exact flavor of the OS and whether the processor is 32-bit or 64-bit.

So yes, a process's max memory is different than the system's total virtual memory.

System design is impacted if you're trying to create a system using very large data structures, particularly
if your software's running on a system with other apps. Your design needs to make careful use of memory
to make sure you're not going to run out of virtual memory. Furthermore, since virtual memory is a
combination of physical memory and swap file space, you need to take care to avoid paging -- or at least
minimize it as much as possible. This means you should have an understanding of the environment your
software's going to run in. At the minimum, you should have good documentation explaining your
assumptions, estimated system requirements and projected system impacts.
c

ccc 

  c c c6c cc"cc

An ActiveX Dll runs is an in process server running in the same memory space as the client process. It is an
in-process component shares its client·s address space, so property and method calls don·t have to be
marshaled. This results in much faster performance. If an unhandled error occurs it will cause the client
process to stop operating.c

An ActiveX Exe is an out of process server which runs in it's own separate memory space. The component
can run as a standalone desktop application, like Microsoft Excel or Microsoft Word, in addition to
providing objects.c

The component can process requests on an independent thread of execution, notifying the client of task
completion using events or asynchronous call-backs. This frees the client to respond to the user.
If an error occurs the client processes can continue to operate. It is generally slower than an ActiveX dll
alternative.c

ccc  +($ c* c2+($ c cc$ 


  c(cc

In strongly-typed programming languages you usually have to declare variables prior to using them.
Strong-typing is the strict enforcement of [type] rules. All types (int, short, long, string) are know at
compile time and are statically bound. So C# is a strongly-typed language because variables must be
assigned a type before you use them. If you came from the ASP world then you will remember having to
use either Javascript or VBScript. Variables that you declare in either of those languages can hold any data
type which makes it weakly-typed. strong-typing means a strict enforcement of type rules with no
exceptions as opposed to weak-typing which allows well defined exceptions (such as assigning an int to a
float in C++).
While strong-typing can prevent many type errors, weak-typing is much more developer ´friendlyµ.
I assumed the preffered enforcement mechanism depends on the application at hand

But lets take this up a level. Instead to talking about programming languages, lets talk about strongly-
typed/weakly-typed objects. The DataSet object is a great example. If we use a weakly-typed dataset, the
developer needs to know the name of the table and the name of the field being requested. Since we are
just passing strings, this code will compile and will not show any possible problems (like typing the name
of the table wrong) until run time.

string s = (string) myDataSet.Tables["Customers"].Rows[0]["CustomerID"];

If our Dataset is Strongly-Typed, we are able to access the names of the tables and columns directly. Any
errors are caught at compile time.

string s = myDataSet.Customers[0].CustomerID;

I am not really going to argue which is better, I will leave that up to you. I will leave you with this question
though; would you rather catch your errors at compile time, or run-time?
c

  9c $   c c c #$  c    #c c c c !c $  c    c c $c
ccc c * c(cc

System.Web.UI.Page, System.Windows.Forms.Form and System.ComponentModel.Container


The essence of component development is not to build what you can buy. Buy a rich text web control
from the market for $99 instead of design and implement one from scratch. Snapping together pre-tested
components are faster, cheaper and probably more reliable than coding everything for yourself.

What is a '.NET component'? Arguably, almost any .NET class file is a component, in that it can easily be
compiled to a DLL, it benefits from .NET versioning, and it can be reused. If you narrow the definition to
components that are 'designable', in other words you can drop instances onto a Visual Studio .NET design
surface and set their properties or create event handlers visually, then you need a class that directly or
indirectly implements IComponent. Designable objects do not necessarily have a user interface. Those
that do are controls as well as components, and inherit from System.Windows.Forms.Control or
System.Web.UI.Control.
The existence of components also implies the existence of containers, which again may be visual or non-
visual. In the .NET Framework both ASP.NET Web Forms and rich client Windows Forms are visual
component containers. The container plays an important role in component management. In particular, all
containers implement IDisposable, which means they have a Dispose method for releasing unmanaged
resources such as window handles or open files. In their Dispose method, containers must also call
Dispose on all the components they host.

ccc"cccc
c c  cc(cc

The PID is an integer that is assigned to each process in your operating system.It is usefull when you need
to diagnose problems with your application since it allows you to uniquely identify each process.

cIn the .Net framework, you can access this information by using the System.Diagnostics namespace.

c (c$  c  c c cc c:c$ cc

Only one.c

ccc5cc$ c cc*c

GAC=Global Assembly Cache, solves dll versioning(hell) problem. It's interesting to know how it solves the
problem, each assembly is uniquely identified by 4 'things' major version number,minor version, build and
revision numbers.For each differing version, the GAC silently creates a subfolder based on a hash of these
and places the assembly in it.From a user perspective it seems as if, we are moving the same file in one
directory and it doesn't ask if it should overwrite the file !

Unlike earlier situations, GAC can hold two assemblies of the same name but different version. This
ensures that the applications which access a particular assembly continue to access the same assembly
even if another version of that assembly is installed on that machine

 +*cc"*$ c

" c c 

  c  c  
 +   1c G +   c  c $ +   c
$   cc

Interface oriented programming defines a contract between two parties - a rule that both stick to and
neither care how the other is providing the functionality. Classic example would be COM.

Object Oriented Programming: A programming methodology which models software in the natural way
as they are represented in the real world objects. The core tenets are Abstraction, Encapsulation,
Polymorphism and Inheritance. This took reuse to a newer level. Object oriented programming is looking
at things behavioraly - in what they do(methods) and what identifes them(properties).

Aspect-oriented Programming: A programming methodology which is complimentary to OOP when it


comes to handling cross cutting concerns. Cross cutting concerns mean, features which are common
across all the components / classes / applications. An example would be transactions or security. Every
component / class / application needs transactions and security. Instead of every class / method in every
application implementing this, this should be done in one and only place. Security, Transactions, Logging
are examples of such cross cutting concerns. MTS was one of the examples of this, Role based security,
Transactions cross cutting concerns were provided by the container (MTS). Usually this is achieved by
interception. If there is a logic mistake in implementing these cross-cutting concerns then the whole
system will fail. In case of object-oriented whole system will not fail.

" cc c 
 cc cc8c 

  c
cccc

An interface defines a contract. It doesn't provide an implementation. A class can and usually provides an
implementation.c

cc 
  c

 contain modules, modules contain types, and types contain members. Reflection provides
objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an
instance of a type, bind the type to an existing object, or get the type from an existing object. You can
then invoke the type's methods or access its fields and properties. Typical uses of reflection include the
following:

Use ( to define and load assemblies, load modules that are listed in the assembly manifest, and
locate a type from this assembly and create an instance of it.

Use   to discover information such as the assembly that contains the module and the classes in the
module. You can also get all global methods or other specific, nonglobal methods defined on the module.
Use     
 to discover information such as the name, parameters, access modifiers (such as
public or private), and implementation details (such as abstract or virtual) of a constructor. Use the
5     or 5    method of a ($ to invoke a specific constructor.

Use  
 to discover information such as the name, return type, parameters, access modifiers
(such as public or private), and implementation details (such as abstract or virtual) of a method. Use the
5  or 5 method of a ($ to invoke a specific method.

Use  
 to discover information such as the name, access modifiers (such as public or private) and
implementation details (such as static) of a field, and to get or set field values.

Use * 
 to discover information such as the name, event-handler data type, custom attributes,
declaring type, and reflected type of an event, and to add or remove event handlers.

Use  $ (


 to discover information such as the name, data type, declaring type, reflected type, and
read-only or writable status of a property, and to get or set property values.

Use   
 to discover information such as a parameter's name, data type, whether a parameter
is an input or output parameter, and the position of the parameter in a method signature.

Use  " to discover information about custom attributes when you are working in the
reflection-only context of an application domain. CustomAttributeData allows you to examine attributes
without creating instances of them.

The classes of the ( 


   namespace provide a specialized form of reflection that
enables you to build types at run time.

Reflection is the feature in .Net, which enables us to get some information about object in runtime. That
information contains data of the class. Also it can get the names of the methods that are inside the class
and constructors of that object.

To write a C# .Net program which uses reflection, the program should use the namespace
System.Reflection. To get type of the object, the typeof operator can be used. There is one more method
GetType(). This also can be used for retrieving the type information of a class. The Operator typeof allow
us to get class name of our object and GetType() method uses to get data about object?s type. This C#
tutorial on reflection explains this feature with a sample class.
c

d cc
  dc
c

d c
  d c
c
ccc  cc

cc
c
c
d c
  d  cc
c
ccc  ccc
c
c
d c c  c
c
d c c c
c
ccc c  c
c
d c c
 c
c
ccc c  c
c

cc

c
At first we should get type of object that was created. The following C# .Net code snippet shows how to
do it.


  dc   ccc
  d c
 dc  dcc     d c

Now objectType has all the required information about class TestDataType. We can check if our class is
abstract or if it is a class. The System.Type contains a few properties to retrieve the type of the class:
IsAbstract, IsClass. These functions return a Boolean value if the object is abstract or of class type. Also
there are some methods that return information about constructors and methods that belong to the
current type (class). It can be done in a way as it was done in next example:
c

 dc  dcc     d c


c
   !c"#c!cc  d     c
$ %&!c"#c' %&cc  d $ %& c
c
((c) cc %c   c
* + ,    -,c
!% c    !c!cc!cc
c
ccc * + !c
c
c
* + c
((c) cc %c' %&c
* + ,$ %&-,c
!% c$ %&!c'!cc' %&cc
c
ccc * + '!c
c
c

Now, the above program returns a list of methods and constructors of TestDataType class.

Reflection is a very powerful feature that any programming language would like to provide,
because it allows us to get some information about objects in runtime. It can be used in the
applications normally but this is provided for doing some advanced programming. This might be
for runtime code generation (It goes through creating, compilation and execution of source code
in runtime).

ccc 

  c c6cc * c c6c cc  c cGcc

 cc($c(c $   c(c6 c ccc $ cc

 $(1cccc 

  c c (+  c c+  cc

c c( cc c 


  c c (  c 
  cc

 c c c(  c c( cc$$ $ cc

cc c(c3
 ccccc
 cccc 

  cc

cc* c( /#
 #0;cc

ccc  (+  c(c 

  c
c cc 8c  (+  cc

 c"cc cc

ccc<ccc5cc c c c 


c
c cc

c cc   c c   c ccc c c c
ccc  +
   c
 4 cc

ccc 

  c c 4/0c c"$/0cc

c c c  /0c $ c 


c c c "$c c c c $$ c    c

 4 cc

c cc
c  c c c2c:c#  =#cc

ccc 

  c c +$  c c+
+$  cc

c  (c c+


+$  c    c ccc

 c(8 c   cc $  c c1cc$  ccc   c c c c
6c c½---c c½--!c
  c"*$ :  c

8c  ccc c2cc" /(  0;cc

c c",c cc(cc  c


 c  cc 2cc

cc (  c $&(c c(ccc$  cc

 cc  c 2/0c$c> c  2?cc cc  c  c  cc* c cc

cc c"c58 cc*c cc

c 
c c( c  c  *c
c(c   ccc c   c$ 
 c  (c
$  cc

c cc c c:c@c


 c:c#  #cc

What does this do? sn -t foo.dll

What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

Contrast OOP and SOA. What are tenets of each?

How does the XmlSerializer work? What ACL permissions does a process using it require?

Why is catch(Exception) almost always a bad idea?

What is the difference between Debug.Write and Trace.Write? When should each be used?

What is the difference between a Debug and Release build? Is there a significant speed difference? Why
or why not?

Does JITting occur per-assembly or per-method? How does this affect the working set?

Contrast the use of an abstract base class against an interface?

What is the difference between a.Equals(b) and a == b?

In the context of a comparison, what is object identity versus object equivalence?

How would one do a deep copy in .NET?

Explain current thinking around IClonable.

What is boxing?

Is string a value type or a reference type?


What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does
it attempt to solve?

Why are out parameters a bad idea in .NET? Are they?

Can attributes be placed on specific parameters to a method? Why is this useful?

C# Component Developers

Juxtapose the use of override with new. What is shadowing?

Explain the use of virtual, sealed, override, and abstract.

Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0,
Culture=neutral, PublicKeyToken=593777ae2d274679d

Explain the differences between public, protected, private and internal.

What benefit do you get from using a Primary Interop Assembly (PIA)?

By what mechanism does NUnit know what methods to test?

What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}

What is the difference between typeof(foo) and myFoo.GetType()?

Explain what·s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} }
How is this construct useful?

What is p? Can this be used within a static method?

ASP.NET (UI) Developers

Describe how a browser-based Form POST becomes a Server-Side event like Button1_OnClick.

What is a PostBack?

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?

What is the <machinekey> element and what two ASP.NET technologies is it used for?

What three Session State providers are available in ASP.NET 1.1? What are the pros and cons of each?

What is Web Gardening? How would using it affect a design?

Given one ASP.NET application, how many application objects does it have on a single proc box? A dual?
A dual with Web Gardening enabled? How would this affect a design?
Are threads reused in ASP.NET between reqeusts? Does every HttpRequest get its own thread? Should
you use Thread Local storage with ASP.NET?

Is the [ThreadStatic] attribute useful in ASP.NET? Are there side effects? Good or bad?

Give an example of how using an HttpHandler could simplify an existing design that serves Check Images
from an .aspx page.

What kinds of events can an HttpModule subscribe to? What influence can they have on an
implementation? What can be done without recompiling the ASP.NET Application?

Describe ways to present an arbitrary endpoint (URL) and route requests to that endpoint to ASP.NET.

Explain how cookies work. Give an example of Cookie abuse.

Explain the importance of HttpRequest.ValidateInput()?

What kind of data is passed via HTTP Headers?

Juxtapose the HTTP verbs GET and POST. What is HEAD?

Name and describe at least a half dozen HTTP Status Codes and what they express to the requesting
client.

How does if-not-modified-since work? How can it be programmatically implemented with ASP.NET?
Explain <@OutputCache%> and the usage of VaryByParam, VaryByHeader.

How does VaryByCustom work?

How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated
via all values of q= except where q=5 (as in $ :: :$$&'A*)?

Developers using XML

What is the purpose of XML Namespaces?

When is the DOM appropriate for use? When is it not? Are there size limitations?

What is the WS-I Basic Profile and why is it important?

Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. Include
elements from both namespace.

What is the one fundamental difference between Elements and Attributes?

What is the difference between Well-Formed XML and Valid XML?


How would you validate XML using .NET?

Why is this almost always a bad idea? When is it a good idea? myXmlDocument.SelectNodes("//mynode");

Describe the difference between pull-style parsers (XmlReader) and eventing-readers (Sax)

What is the difference between XPathDocument and XmlDocument? Describe situations where one
should be used over the other.

What is the difference between an XML "Fragment" and an XML "Document."

What does it meant to say ´the canonicalµ form of XML?

Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to
solve?

Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?

Does System.Xml support DTDs? How?

Can any XML Schema be represented as an object graph? Vice versa?

You might also like