ஒரு பார்வை

June 21, 2006

My Notes – ASP.NET

Filed under: ASP/ ASP.NET — CAPitalZ @ 4:00 pm

Every Web page in .NET

extends System.Web.UI.Page class

==

IL is short for Intermediate Language

Another term for IL is Managed Code. This intermediate or managed code is generated by the JIT compiler. JIT is short for Just in Time compiler.

The C#, VB.NET, Cobol.NET, and all other compilers that support the .NET Framework generate IL when compiling a set of code.  To get an idea of what IL looks like, start up ILDASM by opening a Visual Studio .NET Command Prompt (Start -> All Programs -> Microsoft Visual Studio .NET -> Visual Studio .NET Tools -> Visual Studio .NET Command Prompt) and type ILDASM.  The ILDASM tool is an IL Disassembler for the .NET framework which is installed as part of the .NET SDK.  To view the IL for any .NET component on your system go to File -> Open and select a .NET assembly.

How to write ILAsm

http://www.codeproject.com/dotnet/ilassembly.asp

==

The GAC (aka Global Assembly Cache) is the central repository for assemblies installed on a Windows machine. It provides a uniform, versioned and safe access of assemblies by their strong assembly name.  C:\WINDOWS\assembly

DataReader 

You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Results are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the DataReader. Using the DataReader can increase application performance both by retrieving data as soon as it is available, rather than waiting for the entire results of the query to be returned, and (by default) storing only one row at a time in memory, reducing system overhead.

Note that while a DataReader is open, the Connection is in use exclusively by that DataReader. You will not be able to execute any commands for the Connection, including creating another DataReader, until the original DataReader is closed.

Output parameters or return values are only available through the DataReader once the connection is closed.

==DataAdapter

Adapters are used to exchange data between a data source and a dataset.

  • To retrieve rows into a dataset, use the Fill method on a data adapter object. When you invoke the Fill method, it transmits an SQL SELECT statement to the data store.

·          To transmit a dataset table of the dataset to the data store, use the adapter’s Update method. When you invoke the method, it executes whatever SQL INSERT, UPDATE or DELETE statements are needed, depending on whether the affected record is new, changed, or deleted.

==

DataView

A data view is an object that acts as a layer on top of the data table, providing a filtered and sorted view of the table’s contents. A data view is similar to a view in a database, in that it is not a copy of the data. Instead, it is simply a different way of seeing the data in a table.

==

DataGridThe DataGrid Web server control displays data in a tabular layout. By default, the DataGrid displays data in read-only mode, but the DataGrid is also capable of automatically displaying the data in editable controls at run-time. The DataGrid control can also create the Select, Edit, Update, and Cancel buttons and programming structure. Additionally, the DataGrid supports paging, though you may also use the custom navigation features of the control to improve performance by controlling the amount of data sent to the client browser.

DataSetDatasets store data in a disconnected cache. The structure of a dataset is similar to that of a relational database; it exposes a hierarchical object model of tables, rows, and columns. In addition, it contains constraints and relationships defined for the dataset.

You can populate a dataset in a variety of ways:

  • Call the Fill method of a data adaptery.

  • Manually populate tables in the dataset by creating DataRow objects and adding them to the table’s Rows collection. (You can only do this at run time; you cannot set the Rows collection at design time.)

  • Read an XML document or stream into the dataset. For more information, see the ReadXml method.

  • Merge (copy) the contents of another dataset. This scenario can be useful if your application gets datasets from different sources (different XML Web services, for example), but needs to consolidate them into a single dataset. For more information, see the DataSet.Merge method.

== 

ViewStateBefore ASP.NET, restoring the values back into the form fields across multiple postbacks was entirely the responsibility of the page developer, who had to pick them out, one-by-one, from the HTTP form, and push them back into the fields. Happily, ASP.NET does this trick automatically, thus eliminating both a lot of grunt work and a lot of code for forms. But that’s not ViewState.

ViewState is the mechanism ASP.NET uses to keep track of server control state values that don’t otherwise post back as part of the HTTP form. For example, the text shown by a Label control is saved in ViewState by default. As a developer, you can bind data or programmatically set the Label just once when the page first loads, and on subsequent postbacks, the label text will be repopulated automatically from ViewState. So in addition to less grunt work and less code, the benefit of ViewState is often fewer trips to the database.

It’s a hidden form field managed by the ASP.NET page framework. When ASP.NET executes a page, the ViewState values from the page and all of the controls are collected and formatted into a single encoded string, and then assigned to the value attribute of the hidden form field (specifically, <input type=hidden>).

– You must have a server-side form tag (<form runat=server>) in your ASPX page if you want to use ViewState.

– In cases where the page does not post back, you can eliminate ViewState from a page by omitting the server side <form> tag.

Not very good for:

Large amounts of data.Secure data that is not already displayed in the UI

Objects not readily serialized into ViewState, for example, DataSet.

Disabling ViewState

Per control (on tag)

<asp:datagrid EnableViewState="false" … />

Per page (in directive)

<%@ Page EnableViewState="False" … %>

Per application (in web.config)

<Pages EnableViewState="false" … />

  

 

 

Trace.Write()

==

Rich output caching. ASP.NET output caching can dramatically improve the performance and scalability of your application.  When output caching is enabled on a page, ASP.NET executes the page just once, and saves the result in memory in addition to sending it to the user.  When another user requests the same page, ASP.NET serves the cached result from memory without re-executing the page.   Output caching is configurable, and can be used to cache individual regions or an entire page.

==

Web-Farm
Session
State. ASP.NET session state lets you share session data user-specific state values across all machines in your Web farm.  Now a user can hit different servers in the web farm over multiple requests and still have full access to her session.  And since business components created with the .NET Framework are free-threaded, you no longer need to worry about thread affinity.

===

Managed code is compiled for the .NET run-time environment. It runs in the Common Language Runtime (CLR), which is the heart of the .NET Framework. The CLR provides services such as security, memory management, and cross-language integration. (3) Managed applications written to take advantage of the features of the CLR perform more efficiently and safely, and take better advantage of developers’ existing expertise in languages that support the .NET Framework.

There can be no memory leaks in 100% managed code.

Another significant advantage of using managed code is that the CLR provides automatic lifetime management of components and modules. Lifetime control includes:

  • Garbage collection, which frees and compacts memory.

  • Scalability features, such as thread pooling and the ability to use a non-persistent connection with a dataset.

  • Support for side-by-side versions.

Managed code does not have direct access to memory, machine registers, or pointers.

===

if a method input parameter is declared as accepting a 4-byte value, the common language runtime will detect and trap attempts to access the parameter as an 8-byte value. Type safety also means that execution flow will only transfer to known method entry points. There is no way to construct an arbitrary reference to a memory location and cause code at that location to begin execution

Unmanaged code includes all code written before the .NET Framework was introduced—this includes code written to use COM, native Win32, and Visual Basic 6. Because it does not run inside the .NET environment, unmanaged code cannot make use of any .NET managed facilities.

==

All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.

Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes – e.g. determining data type sizes for marshaling data across context/process/machine boundaries.

Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

==

Code Access Security

CAS is the part of the .NET security model that determines whether or not code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.

C# supports constructor chaining

class Person
    {
        public Person( string name, int age ) { ... }
        public Person( string name ) : this( name, 0 ) {}
        public Person() : this( "", 0 ) {}
    }

===

User Control vs Custom Control [Composite Control]

The main difference between user controls and composite controls is that user controls are persisted as .ascx text files, whereas composite controls are compiled and persisted in assemblies.

A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user’s previous work experience).

An ASP.NET control (sometimes called a server control) is a server-side component that is shipped with .NET Framework. A server control is a compiled DLL file and cannot be edited. It can, however, be manipulated through its public properties at design-time or runtime. It is possible to build a custom server control (sometimes called a custom control or composite control).

==

all .NET event handlers are expected to accept two parameters.The first parameter (Sender) is a reference to the object that raised theevent. You might think this is redundant because we’ve already decidedthat this handler will be associated with events from the Navigate button;however, as we shall see in Chapter 4, you can define eventhandlingroutines to be associated with multiple controls, and so theSender parameter provides an easy way to identify which of thesecontrols has raised the event.The second parameter (E) is a reference to an object that provides additionalinformation about the event. In the case of a click event there’s nouseful additional information, but for events such as ItemClick (ina ListBox) or ItemCommand (in a DataGrid) the E parameter includes

details of which item or row has been selected or activated.

Typed versus Untyped Datasets

Datasets can be typed or untyped. A typed dataset is a dataset that is first derived from the base DataSet class and then uses information in an XML Schema file (an .xsd file) to generate a new class. Information from the schema (tables, columns, and so on) is generated and compiled into this new dataset class as a set of first-class objects and properties.

      Note For more information about dataset schemas, see XML Schemas and Data.

Because a typed DataSet class inherits from the base DataSet class, the typed class assumes all of the functionality of the DataSet class and can be used with methods that take an instance of a DataSet class as a parameter

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.)

You can use either type of dataset in your applications. However, Visual Studio has more tool support for typed datasets, and they make programming with the dataset easier and less error-prone.

=========

SERVER controls vs CLIENT controls.. ASP.NET

http://www.informit.com/articles/article.asp?p=173412&rl=1

=========

 CMS

Software that provides a method of managing your website is commonly called a CMS or “Content Management System”. Many blogging software programs are considered a specific type of CMS.

=========

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: