Monday, May 12, 2008

ADO.NET

ADO.NET (ActiveX Data Objects) is set of classes that expose data access services to the .NET application.
It uses 2 types of objects to access data from database.
a. Datasets
b. .NET Data Provider Objects - Data Adapters, Commands , Connections

Dataset holds entire database int it. So we can have the data inserted, updated in it though the connection is lost from the datasource. this is referred to as Disconnected architecture.

DataAdapter serves as a bridge between dataset and a datasource for retrieving and saving data
Used to exchange data between datasource and dataset.

To trnasmit a database table of dataset to the datastore, dataadapters Update method can be used. When thos method is invoked, it executes whatever SQl INSERT, UPDATE, DELETE statements are needed depending on the affected record is new, changes or deleted.

Connection pooling enables an application to use a connection from a pool of connections that do not need to be re established for every use. Once connection has been created and placed in connection pool, application can reuse the connection without performing the complete connection creation process.

Web Services

A Web Service is a Software component stored in one machine that can be accessed by another application in another machine over a network.

Methods in Web Service are invoked through a Remote Procedure Call(RPC).

SOAP (Simple Object Access Protocol) is a platform independant protocol that uses XML to make Remote Procedure Calls.

When a program invokes a Web Method , the request and all relevant info is packaged in a SOAP message and sent to the server where Web Service resides.
A Web Service receives SOAP message, parses its contents to determine the method program wishes to execute and method parameters.
After a web service parses a SOAP message a proper method is called and response is sent back to the client in another SOAP message.

Client and a Web Service communicate using messages, specifically SOAP messages by default. Client sends a SOAP request to a Web Service, and a Web Service method typically returns a SOAP response. Web Services define the type of messages they accept using operations, defined by Web Services Description Language (WSDL). The data that is eventually communicatedover the network must be serialized into XML.

A Web Method tells the .NET that perticular public method should be exposed as a Web-Callable method.

WSDL is written in XML. It is an XML document. It si used to describe Web Services. Used to locate Web Services.

Four major parts of WSDL document
a. WSDL Ports - describes operations that can be performed, messages that are involved.
b WSDL Messages - Defines the data elements of an operation.
c. WSDL Types - Defines the datatype that are used by the Web Service.
d. WSDl Bindings - Defines message format and protocol details for each port.

Sunday, May 11, 2008

.NET Framework

The .NET Framework is a development and execution environment that allows different programming languages & libraries to work together seamlessly to create Windows, Web, or Mobile applications that are easier to build, manage, deploy, and integrate with other networked systems or as stand alone applications.

AJAX

Asynchronous Javascript and XML
1. Is combination of technologies that allows content of a web page to be updated or changed without the entire page being re loaded.
2. AJAX can be implemented in Browsers that do not support XMLHTTPRequest object. possible using remote scripts.
3. AJAX technology is independant of web servers. AJAX is client Technology.
4. AJAX is supported in IE 5 and above, Netscape, Opera, safari, Firefox
5. responseText and responseXML are properties
6. overrideMimeType(), setRequestHeader(), getResponseHeader() are the methods
7.
ASP.NET Ajax is a free framework for quickly creating efficient and interactive web applications that word across all popular browsers
8. AJAX Control toolkit can be downloaded for ASP.NET 2.0. But is a part of ASP.NET 3.5 framework
9. Version 1.0.20229 for .NET 1.0 and 2.0
10. Version 3.5.20229 for .NET 3.5
11. Dojo is modular open source Javascript toolkit designed to ease the rapid development of AJAX based applications
12. Multiple AJAX requests can be made by creating multiple XMLHHTTPRequest objects.
13. ScriptManager is a server side control that sits on your web form and enables core of ASP.NET AJAX.
14. Its primary role is the arbitration of all other ASP.NET AJAX controls on the web form and addition of the right scripting libraries to the web browser so that client portion of ASP.NET AJAX can function
a. Managing all resources on a web page
b. Managing partial page updates
c. Download AJAX script library to the client
d. Interacting with UpdatePanel and UpdateProgress controls
e. Register script (Using RegisterClientScriptBlock)
f. Providig access to web service methods by registering web services with the ScriptManager control.
g. Providing access to ASP.NET Authentication, role and profile application services from client script after registering these from ScriptManager control.
h. Enable culture specific display of client side script.
i. Register server controls that implement IExtenderControl and IScriptControl interfaces
15. Multiple ScriptManager controls cannot be used in a web page

Differences between 1.1 and 2.0

1. Generics are introduces in 2.0
2. Master Pages introduced in 2.0
3. Nullable datatypes introduced in 2.0
4. Profile Object introduced in 2.0
5. 2.0 Has built in Web Server
6. This article outlines changes to the code model, compilation, page lifecycle, and more - http://msdn2.microsoft.com/en-us/library/ms379581(VS.80).aspx

Saturday, May 10, 2008

Helpful Points

1. Master Pages are not available in ASP.NET 1.1
2. Datareader can be provided as datasource for GridView in web applications only, but paging and sorting will be difficult. Also data cannot be updated.
3. In ADO.net for Command Object you have 3 methods
a.ExecuteReader - Select statements
b.ExecuteNonQuery - DML statements(Insert,Update and Delete)
c.ExecuteScalar - Returns a single value from Aggragate functions like SUM,AVG,COUNT etc
4. machine.config settings are applicable to all the applications running on that server, web.config settings are applicable to only that application
5. An application can havemore than 1 web.config file, but they should be in different directories of that web application also the sub directory that uses it must be a virtual directory.
6. One website can have 20 cookies with 4kb per cookie.
7. To Maintain viewstate of Dynamic controls, bind them in Init event. because if done in Page Load, it would have already set default values.
8. There are three types of JIT compilers
a. Pre: This JIT compiles the whole application
b. Econo: This compiles the modules called at RunTime
c. Normal: This compiles modules called at runtime and keep it in cache
9. Caching is the technique of persisting data in memory for immediate access to requesting program calls.
10. This is considered as the best way to increase performance of the application
11. Caching is of 3 Types
a. Output Caching : Caches the whole page.
b. Fragment Caching : Caches only a part of the page.
c. Data Caching: Caches the data.

12. Authntication is giving access to the site
13. Authorization is giving access to perform some operations in site
14. Request.ServerVariables["SERVER_SOFTWARE"] gives which version of IIS application is using.
15. Permanent cookie can be created from following code
HTTPCookie c = new HTTPCookie ("MyCookie", "MyText");
c.Expires = DateTime.MaxValue;
Respon.Cookies.Add(c);
16. In ADO.NET data is sent in XML format hence easily sent across firewalls whereas in other languages data is sent in binary format which firewall poses problems
17. When AutoEventWireup is true ASP.NEt need not require events to specify event handlers like Page_Init, Page_Load. Means handles keyword not required in VB.
In the case where AutoEventWireup attribute is set to false (by default), event handlers are automatically required for Page_Load or Page_Init. However, when we set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.
18. ASP.NET application can be run without WEB.CONFIG since all the settings required for an ASP.NE application is available in MACHINE.CONFIG
19. WEB.CONFIG if present for any application overrides settings in MACHINE.CONFIG for that application.
20. Garbage Collector is mainly used for Automatic Memory Management. Monitor leaked or unused memory objects that are loaded into memory. Garbage Collector releases memory objects. Cannot say when this runs. but can be called programmatically
system.gc.collect(); but not recommended
21. Reflection is used for Late Binding of Objects in .NET. By using reflection one can use COM components and create objects of them at Runtime. It invokes properties and objects of that COM.
22. DataSet.Clone() creates new instance of same object.
23. DataSet.Copy() Copies content of data to another object without creating new instance
24. Web parts allows the user to customize how site looks. Present only in 2.0
25. Web Services used SOAP and HTTp protocols. message is first converted to XML and serializes and sent through HTTP protocol to the server. In Server again it deserializes and from XML file it gets info it wanted. As message is sent as XML it is platform independant.
Remoting allows us to enjoy the same power of web services when the platform is same. We can connect directly to server over TCP and send binary data without having to do lots of conversation.
26.


ASP.NET Web Services

.NET Remoting

Protocol

Can be accessed only over HTTP

Can be accessed over any protocol (including TCP, HTTP, SMTP and so on)

State Management

Web services work in a stateless environment

Provide support for both stateful and stateless environments through Singleton and SingleCall objects

Type System

Web services support only the datatypes defined in the XSD type system, limiting the number of objects that can be serialized.

Using binary communication, .NET Remoting can provide support for rich type system

Interoperability

Web services support interoperability across platforms, and are ideal for heterogeneous environments.

.NET remoting requires the client be built using .NET, enforcing homogenous environment.

Reliability

Highly reliable due to the fact that Web services are always hosted in IIS

Can also take advantage of IIS for fault isolation. If IIS is not used, application needs to provide plumbing for ensuring the reliability of the application.

Extensibility

Provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages.

Very extensible by allowing us to customize the different components of the .NET remoting framework.

Ease-of-Programming

Easy-to-create and deploy.

Complex to program.

Important Points to Note 2

1. inetinfo.exe is the microsoft IIS server running, handling ASP.NET requests. When an ASP.NET request is received, the ISAPI filter aspnet_isapi.dll takes care of it by passing the request o the actual worker process aspnet_wp.exe
2. Page Load events
a. Init()
b. Load()
c. PreRender()
d. UnLoad()
3. ViewState is available after Init() and before Page_Load().
4. A Web Page is an instance of System.Web.UI.Page
5. Information about users locale is stored in System.Web.UI.Page.Culture
6. Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs", Codebehind is used only in Visual Studio .NET
7. range Validator supports Integer, String, Date datatypes
8. All User input data should be validated at server side. additionally client side code can be provided for richer and more responsive experience for the user
9. Server. Transfer transfers page processing from one page to another without making round trip back to the client browser. This provides faster response and little less overhead on the server. It does not update history list.
10. Response.redirect performs a round trip back to the clients browser where client browser is redirected to new page . Users history list is updated
11. ADO.NET
a. can represent an entire relational database, tables, relations, views
b. can work without continuing connection with the datasource
c. data in dataset is bulk loaded, ather than loading on demand
d. No concepts of cursors in dataset
e. No current record pointer, can use for each to loop through records
f. Can store many edits in dataset and write them to original datastore in single operation

12. Global.asax is used to implement application and session level events.
13. Diffgram is one of the 2 XML formats that can be used to render dataset object contents to XML file. Useful when reading database data and sending it to WebService through XML.
14. MSIL allows the .NET Framework to JIT compile the assembly on the installed computer.
15. data cannot be edited in Repeater control
16. ControlToValidate and Text property are the 2 common properties found in all Validation controls
17. A single .NET DLL can contain many classes
18. SOAP - Simple Object Access Protocol is the protocol used to call a Web Service.
19. Web Service can be written in any language
20. WSDL stands for - Web Services Description Language
21. ViewState allows the state of serializable objects to be stored in a hidden field on a page.
It is transported to the client and back to the server.
It is not stored in server or any other external Source
It is used to retain the state of server side objects between postbacks
22. ASP.NET provides In-Process and Out-of-Process state management.
In-Process stores the session in memory in Web Server. It requires "sticky-server" (no load balancing) so that the user is always reconnected to the same web server.
Out-of-Process sesion state management stores data in an external data source. Exernal device may be SQl Server or State Server service.
Out-of-Process state management requires all objects stored on session are serializable

Important Points to Note

1. Every class is derived from System.Object
2. Immutable - Data value may not be changed. variable value may be changed, but the original immutable data is discareded and new data value is created in memory.
3. Finally block will be executed even though the exception occurs.
4. "Sealed" keyword prevents your class from being inherited.
5. You can make class public but method as sealed will prevent method from being overridden
6. "Abstract Class" - Class cannot be instantiated. So it must be Inherited
7. Multiple interfaces can be implemented, but multiple classes cannot be inherited
8. Inside interface access modifiers cannot eb specified as all methods has to be implemented by class. So they all must be public and hence they are public by default.
9. Difference between Interface and Abstract class.
Interface Abstract
a. all methods are abstract Some methods can be concrete
b. there is no implementation implementations can be present
c. no accessibility modifiers allowed allowed
10. "Virtual" keyword says method or property can be overridden
11. Delegate object encapsulates a reference to a method. mainly used in events.
12. Debug class can be used for Debug builds, Trace can be used for both Debug and Release builds.
13. DLL Hell - Assembly versioning allows applications to specify not only lirary it needs to run, but also the version of the assembly
14. Floowing are different ways of deplyong assembly
a. MSI Installer
b. CAB Archive
c. XCOPY Deployment
15. When we write Multi Lingual applications and want to distribute core application seperately from the localized modules, the localized assemblies that modify the core application are called
16. Assembly is the smallest unit of execution in .NET
17. System.Globalization and Sstem.resources namespaces are neccessary to create localized applications
18. You should not call Garbage collector. However, you caould call garbeg collector when you are done using a large object to force the garbage collector to dispose of those very large objects from memory. But still this is usually not a good practice.
19. Using Boxing Value Type can be converted into Reference Type
20. Since Boxing converts value type to reference type object will be stored in Heap
UnBoxing converts reference type to value type so, object will be stored in Stack