.Net Framework: Is an environment that facilitates Object Oriented Programming Model for multiple languages. It wraps OS and insulates Software Development from many OS specific tasks such as file handling, memory allocation & management.
It has two main components CLR and .Net Class Libraries.
CLR: Common Language Runtime. It is heart of .Net Framework. Core of CLR is it's execution engine which loads, executes and manages the managed code that has been compiled to Intermediate Language (MSIL).
CTS: Common Type System. It defines the common set of types that can be used in different languages regardless of OS and hardware. Each language is free to provide/define it's own syntaxes.
CTS defines that how types are declared, used and managed in runtime. Most important addition is runtime support for cross language integration. It does:
- Establishes a Framework
- Provides Object Oriented Programming Model
- Defines set of rules that language must follow to be CLR compliant.
CLS: Common Language Specification. It is Subset of CTS which is all .Net languages are expected to implement. Idea behind the CLS is Cross Language Integration.
Managed Code: The .Net framework provides several core run-time services to the programs that run within it. For example exception handling and security. For these services to work the code must provide a minimum level of information to runtime. Such code is called Managed Code.
Managed Data: This is data for which memory management is done by .Net runtime's garbage collector this includes tasks for allocation de-allocation. We can call garbage collector to collect un-referenced data by executing System.GC.Collect()
What is an Assembly?: are fundamental building blocks of .Net Framework. They contains the type and resources that are useful to make an application. Assemblies enables code reuse, version control, security and deployment. An assembly consist of: Manifest, Type Metadata, MSIL and resource file.
Assemblies are Private and Shared. Private are used for a single application and installed in application's install directory or its sub-directory. Shared assembly is one that can be referenced by multiple application and resides in GAC(local cache for assemblies managed by .Net Framework).
gacutil /i myDll.dll can see and %windir%\assembly
Metadata and Menifest: Menifest describes the assembly itself. Assembly name, version, culture, strong name, list of files, type reference and reference assembly. While Metadata describes contents within the assembly like classes, namespaces, interfaces, scope, properties, methods and their parameters etc.
Application Domain: is a virtual process that serves to isolate an application. All object created within the same application scope are created within same application domain.
Garbage Collection: is Automatic Memory Manager for .Net Framework. It manages the memory allocated to .Net Framework.
When a variable is defined it gets a space in memory (stack) and when an object is created memory for the object is allocated in heap. When an object is assigned to a variable it increments the reference counts for the object and when program control comes out of the function the scope of variable gets ended Or NULL is assigned to variable it decrements the reference count of object by 1. When reference count of one object becomes zero GC acts call destructor of object and then releases the memory acquired by the object.
Can .Net Components can be used from a COM? Yes, can be used. But There are few restrictions such as COM needs an object to be created. So static methods, parameterized constructor can not be used from COM. These are used by COM using a COM Callable Wrapper (CCW).
TlbImp.exe and TlbExp.exe
How does .NET Remoting work? It involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is for LANs only and HTTP can be used on LANs or WANs (internet). TCP uses binary serialization and HTTP uses SOAP (.Net Runtime Serialization SOAP Formatter).
There are 3 styles of remote access:
SingleCall: Each incoming request is handled by new instance.
Singleton: All requests are served by single server object.
Client-Activated Object: This is old state-full DCOM model. Where client receives reference to the remote object and keep until it finished with it.
Versioning: MajorVersion.MinorVersion.BuildNumber.Revision
DLL-HELL: situations where we have to put same name Dlls in single directory where are Dlls are of different versions.
Boxing and Un-Boxing: Implicit(automatic) conversion of value type to reference type is known as Boxing And Explicit (manual) conversion of Reference type to value type is said to be Un-boxing. (conversion of Integer variable to object type)
ASP.Net
Different Types of Caching?
Output Caching: stores the responses from an asp.net page.
Fragment Caching: Only caches/stores the portion of page (User Control)
Data Caching: is Programmatic way to Cache objects for performance.
Authentication and Authorization: Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication. Authorization allowing access of specific resource to user.
Different Types of Directives:
Page, Register, Control, OutputCache, Import, Implements, Assembly, Reference
Difference between Server-Side and Client-Side:
Server-Side code is executed on web-server and does not transmitted to client, while client-side code executed on client(browser) and is rendered to client along with the content.
Difference Server.Transfer and Response.Redirect:
Both ends the processing for the current request immediately. Server.Transfer start executing the another resource specified as parameter without acknowledgement to client(browser) while Response.Redirect intimate client that your requested resource is available at this location and then client request for that resource.
Different Types of Validators and Validation Controls:
RequiredFieldValidator, RangeValidator, RegularExpressionValidator, CompareValidator, CustomValidator, ValidationSummary
How to Manage State in ASP.Net?
Client based: ViewState, QueryString and Cookies
Server based: Session, Application.
Difference between User Control and Custom Control:
CUSTOM Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of webApp add reference and use. Normally designed to provide common functionality independent of consuming Application.
3 Types of Session State Modes?
InProc(cookieless, timeout),
StateServer (Server, Port stateConnectionString="tcpip=server:port"),
SQLServer (sqlconnectionstring) and Off.
What is ViewState and How it is managed, Its Advantages/Benefits?
ViewState is a special object that ASP.NET uses to maintain the state of page and all webcontrols/ServerControls within it. It is in this object preserves the states of various FORM elements during post-backs. It is rendered to client(browser) as a Hidden variable __VIEWSTATE under <Form> tag. We can also add custom values to it.
What is web.config and machine.config:
machine.config is default configuration for all applications running under this version, located in %WinDir%\Microsfot.Net\Framework\Version. Settings can be overridden by Web.Config for an specific application Web.Config resides in application's root/virtual root and exists in sub-sequent folders.
Role of Global.asax:
Optional file contains the code to handle Application level events raised by ASP.Net or By HttpModule. This file resides in application root directory. Application_Start, _End, _AuthenticateRequest, _Error, Session_Start, _End, BeginRequest, EndRequest. This file is parsed and compiled into dynamically generated class derived from HttpApplication.
Page Life Cycle: Init, LoadViewState, LoadPostBackData, Load, RaisePostBackDataChangedEvent, RaisePostBackEvents, Pre-Render, SaveViewState, Render, Unload,
(IpostBackDataChangedEventHandler and IpostBackEventHandler)
Error, CommitTransaction, AbortTransaction, Abort
inetinfo.exe, aspnet_isapi.dll aspnet_wp.exe, HttpModules (OutputCache, Session, Authentication, Authorization, Custom Modules Specified) and Then HttpHandlers PageHandlerFactory for *.aspx
Can the action attribute of a server-side <Form> tag be set to a value and if not how can you possibly pass data from a form to a subsequent Page?
No assigning value will not work because will be overwritten at the time of rendering. We can assign value to it by register a startup script which will set the action value of form on client-side.
Rest are Server.Transfer and Response.Redirect.
ASP.Net List Controls and differentiate between them?
RadioButtonList, CheckBoxList, DropDownList, Repeater, DataGrid,
DataList
Type Of Code in Code-Behind class: Server-Side Code.
What might be best suited to place in the Application_Start and Session_Start:
Application level variables and settings initialization in App_Start
User specific variables and settings in Session_Start
Difference between inline and code-behind. Which is best?
Inline is mixed with html and code-behind is separated. Use code-behind, Because Inline pages are loaded, parsed, compiled and processed at each first request to page and remains in compiled code remains in cache until it expires, If expires it again load, parse and compile While code-behind allows to be pre-compiled and provide better performance.
Which Template must provide to display data in Repeater?
ItemTemplate.
How to Provide Alternating Color Scheme in Repeater?
AlternatingItemTemplate
What base class all Web Forms inherit from? System.Web.UI.Page
What method do you use to explicitly kill a user's Session?
HttpContext.Current.Session.Abandon()
How do you turn off cookies in one page of your asp.net application?
We will not use it. But can not turn off cookies from server. To allow or not is a client side functionality.
Which two properties are on every validation control?
ControlToValidate and Text, ErrorMessage
How do you create a permanent cookie?
Set expires property to Date.MaxValue (HttpCookie.Expires = Date.MaxValue)
What is the standard you use to wrap up a call to a Web Service? SOAP
Which method do you use to redirect to user to another page without performing a round trip to Client? Server.Transfer("AnotherPage.aspx")
What is transport protocol you use to call a Web-Service SOAP? HTTP-POST
A Web Service can only be written in .NET? FALSE
Where on internet would you look for Web services? www.uddi.org
How many classes can a single .NET DLL contain? Unlimited.
How many namespaces are in .NET? 124
What is a bubbled event? When you have a complex control like DataGrid. Writing an event processing routine for each object (cell, button, row etc.). DataGrid handles the events of its constituents and will raise its own defined custom events.
Difference between ASP Session State and ASP.Net Session State?
ASP: relies on cookies, Serialize all requests from a client, Does not survive process shutdown, Can not maintained across machines in a Web farm/garden.
Layout: GridLayout and FlowLayout
Web User Control: Combines existing Server and HTML controls by using VS.Net. to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used.
Composite Custom Control: combination of existing HTML and Server Controls.
Rendered custom control: create entirely new control by rendering HTML directly rather than using composition.
Where do you store the information about user's Locale? Page.Culture
Should Validation occur on Client/Server Side for Date Input?
Both. Client-side reduces extra round-trip. Server-Side ensures prevention against hacking and failure against automated requests.
ADO.Net
ADO.Net Components:
Connection, Command, DataReader, DataAdapter
Differentiate between DataSet and RecordSet:
1) DataSet is entire relation DB in memory. Table/Relation/Views While RecordSet is representation of Table. It do not contain information on relationships, Constraints, Keys.
2) DataSet is designed to work in disconnected mode.
3) There's no concept of cursor-types in a DataSet
4) DataSet has no record pointer.
5) You can store many edits in a DS and write them in Original DataSource in a single call.
6) DataSet internally represents data with XML and can be serialized. Thus you can easily retrieve data from a DB and then write directly to XML file or reverse.
DataSet is always disconnected? True
What is advantage of DataReader over DataSet?
DataReader is readonly stream of data returned from the DB as the query executes. It contains one row of data at a time and is restricted to forward-only. Supports to a access multiple result sets but only one at a time and in order retrieved. DataReader needs connection to DB throughout its usage. DataReader is faster than DataSet.
Typed DataSet?
Data access is normally done using indexes on collection in object model. In ADO.Net it is possible to create a variation on a Dataset that supports syntax like DataSet.TableName.Rows(0).ColumnName . Errors in syntax are detected during compile time rather than runtime.
Advantages: Data Designer generates typed ds. When we type ds. We get all table names and column names on row. We do not need to remember.
How to reflect updation of data in dataset to database?
Dim ds As New (Typed)DataSet
Dim da As New SqlDataAdapter("Select Command")
Dim cd As New SqlCommandBuilder(da)
da.Update(DataTable/DataSet, srcTable)
If SELECT command is SP and to update/insert/delete we have created SPs
We can create SqlCommand Objects in Code and assign it to InsertCommand,
UpdateCommand and DeleteCommand Property of adapter.
What are Different types of command can be executed?
ExecutedNonQuery, ExecuteScaler, ExecuteReader (In Execute NonQuery we can use transaction. In other Scaler and Reader we can not use transaction. We do not need to assign transaction to every command if connection string has ENLIST=true; it automatically assigns current transaction in the Context to the command being executed.
How to Set DataRelation between in two columns:
ds.Relations.Add(DataRelation Object)
New DataRelation(ParentColumns(),childColumns())
New DataRelation("RelationName", ParentColumn, childColumn)
New DataRelation("RelationName", ParentColumn, childColumn, CreateConstraint = True)
New DataRelation("RelationName",ParentColumns(),childColumns(),CreateConstraint=True)
How do we sort the data from a DataTable:
DataTable.Select(strFilter, strSort) As DataRow()
New DataView(DataTable) and DataView.Sort = "Column1,Column2,...)
How do we get only edited/deleted/inserted records from a DataTable:
DataTable.GetChanges(DataRowState.Added Or
DataRowState.Deleted Or
DataRowState.Modified Or
DataRowState.Detached Or
DataRowState.Unchanged)
How does DataAdapter.Fill Work?
Executes the Execute Reader method and gets the reader.
Reads Each ResultSet using NextResultSet of DataReader From the and Fills the DataTable form the reader. Also creates DataTable if MisingSchemaAction is Add/AddWithKey.
Difference between HTML and XML?
XML : User defined tags. Content driven, End tags required , case sensitive. Quotes required around attributes. Slash required in Empty Tags.
What is XSLT and its usage? XSL Transformations. Used to transform XML document to any other text format such as HTML, text, XML etc.
.Net OOPs
Class: Class is concrete representation of an entity. It represents a group of objects, which posses similar attributes and behavior.
Provides Abstraction and Encapsulations. A category name that can be given to group of objects of similar kind.
Object: Object represents/resembles a Physical/real entity. An object is simply something you can give a name.
Object Oriented Programming: is a Style of programming that represents a program as a system of objects and enables code-reuse.
Encapsulation: Binding of attributes and behaviors. Hiding the implementation and exposing the functionality.
Abstraction: Hiding the complexity. Defining communication interface for the functionality and hiding rest of the things.
In .Net destructor can not be abstract. Can define Either Finalize / Destructor. For Destructor access specifiers can not be assigned. It is Private.
Overloading: Adding a new method with the same name in same/derived class but with different number/types of parameters. Implements Polymorphism.
Overriding: When we need to provide different implementation than the provide by base class, We define the same method with same signatures in the derived class. Method must be Protected/Protected-Friend/Public for this purpose. (Base class routine can be called by Mybase.Method, base.Method)
Shadowing: When the method is defined as Final/sealed in base class and not overridable and we need to provide different implementation for the same. We define method with Shadows/new.
Inheritance: Gives you ability to provide is-a relationship. Acquires attributes and behaviors from another. When a class acquires attributes and behaviors from another class. (must not be Final or sealed class in .Net)
Abstract Class: Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes.
Interface: What a Class must do, But not how-to.
Bridge for the communication when the caller does not know to whom he is calling.
Describes externally visible behavior of element.
Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship.
Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface.
Polymorphism: Mean by more than one form. Ability to provide different implementation based on different no./type of parameters.
A method behaves differently based on the different input parameters. Does not depend on the Return-Type.
Pure-Polymorphism: Make an method abstract/virtual in base class. Override it in Derived Class. Declare a variable of type base class and assign an object of derived class to it. Now call the virtual/abstract method. The actual method to be called is decided at runtime.
Early-Binding: Calling an non-virtual method decides the method to call at compile time is known as Early-Binding.
Late-Binding: Same as pure-polymorphism.
Identifiers/Access Specifies and scope:
Private, Protected, Friend, Protected Friend, Public
private, protected, internal, protected internal, public
What is a Delegate?
A strongly typed function pointer. A delegate object encapsulates a reference to a method. When actual function needs to be called will be decided at run-time.
Static Variable and Its Life-Time:
Public Shared VAR As Type Or public static Type VAR;
Life time is till the class is in memory.
Constructor: Special Method Always called whenever an instance of the class is created.
Destructor/Finalize:
Called by GC just before object is being reclaimed by GC.
UML- Unified Modeling Language
A Language provides vocabulary and the rules for combining the words to form sentences for the purpose of communication.
A Modeling Language whose vocabulary is symbols and its rules focuses on the conceptual and physical representation of a system.
UML is a Language for Visualizing, Specifying, Constructing and Documenting a system.
A Model is simplification of reality.
Benefits of model:
- To communicate the structure and behavior of system.
- Visualize and control the system's architecture.
- Better understand the system we are building, So that we might find possibility for simplification and reusability.
- Minimize the risk and Manages the risk.
- Because we cannot understand complex system in its entirety.
The vocabulary of UML encompasses of three kinds of building blocks i.e. Things, Relationships and Diagrams. Things are citizens in a Model, Relationship ties them together and Diagram groups interesting collections of things.
Things in UML: Structural, Behavioral, Grouping and Annotational.
Structural things are:
Class: Rectangle incl. Name, attributes and methods.
Interface: Circle
Collaboration: Ellipse with dashed line.
Use-Cases: Description of Set of sequences of actions performed by a system that yields an observable result of value to a particular actor. Ellipse with Solid Line.
Active Class: whose objects owns one or more processes/threads. Can initiate control activity.
Component: Physical and replaceable part of a system that conforms to provide the realization of set of interfaces.
Node: Physical element that exists at run time and represents computational resource, generally having some memory and processing capability. Cube.
Behavioral things are: Interaction (behavior that comprises set of objects within a particular context for a specific purpose. A direct line arrow) and State-Machine (behavior that defines sequences of states. rounded rectangle).
Grouping things are:
Primary is Package (Organizational part of UML, These are boxes in which model can be decomposed. tabbed folder) others are Framework, Models and Sub-System.
Annotational things are :
Note: (Explanatory part of UML Models, these are comments, dog eared corner rectangle)
Comments