Showing posts with label dot net. Show all posts
Showing posts with label dot net. Show all posts

Sunday, February 15, 2009

Asp .net job interview question

Write a custom function in c-sharp. The custom function parameters should be an instance of a dropdownlist, an xml file and a string.
1. The function should be capabale of populating the passed in dropdownlist.
2. The first item in the dropdownlist should be the passed in string parameter.
3. The data for the dropdownlist comes from the passed in XML file.

The idea is to create a custom function which can be reused through out the project for populating any dropdownlist on any web page. You have 20 minutes to code, test and demonstrate.

The sample code for custom function is shown below. For this example to work drop the XML file in the root folder of the web application.

protected void Page_Load(object sender, EventArgs e)
{
PopulateDropdownlist(DropDownList1, "DropDownListSource.xml", "Select State");
}

public void PopulateDropdownlist(System.Web.UI.WebControls.DropDownList DropDownListObjectToBePopulated,string XMLFilePath, string InitialString)
{
try
{
DataSet DS = new DataSet();
DS.ReadXml(Server.MapPath(XMLFilePath));
if (InitialString != string.Empty)
{
ListItem LI = new ListItem(InitialString, "-1");
DropDownListObjectToBePopulated.Items.Add(LI);
}
foreach (DataRow DR in DS.Tables["State"].Rows)
{
ListItem LI = new ListItem();
LI.Text = DR["StateName"].ToString();
LI.Value = DR["StateCode"].ToString();
DropDownListObjectToBePopulated.Items.Add(LI);
}
}
catch(Exception Ex)
{
}
}

The XML file that has the data for the dropdownlist is as shown below.




Virginia
VA


Iowa
IA


North Carolina
NC


Pennsylvania
PA


Texas
TX



Explanation of the code:
1.
PopulateDropdownlist function has 3 parameters. DropDownList to be populated, the path of the XML file which has the data for the dropdownlist and the initial string.

2. Create an instance of DataSet. In our example the instance is DS.
DataSet DS = new DataSet();

3. Read the XML data into the dataset instance using ReadXml() method. Pass the path of the XML file to ReadXml() method. We used Server.MapPath() method to return the physical file path that corresponds to the specified virtual path on the web server.
DS.ReadXml(Server.MapPath(XMLFilePath));

4. We now have the data from the XML file in the dataset as a DataTable.

5. Check if the InitialString is empty. If not empty create a new ListItem object and populate the Text and Value properties. Then add the listitem object to the dropdownlist.
if (InitialString != string.Empty)
{
ListItem LI = new ListItem(InitialString, "-1");
DropDownListObjectToBePopulated.Items.Add(LI);
}

6. Finally loop thru the rows in the DataTable and create an instance of ListItem class. Populate the Text and Value properties to StateName and StateCode respectively. Finally add the ListItem object to the dropdownlist.
foreach (DataRow DR in DS.Tables["State"].Rows)
{
ListItem LI = new ListItem();
LI.Text = DR["StateName"].ToString();
LI.Value = DR["StateCode"].ToString();
DropDownListObjectToBePopulated.Items.Add(LI);
}

7. Drag and drop the dropdownlist on a webform. Call the PopulateDropdownlist() custom function in the Page_Load event handler. When you call the custom function pass the dropdownlist to be populated, XML file path and the initial string.
protected void Page_Load(object sender, EventArgs e)
{
PopulateDropdownlist(DropDownList1, "DropDownListSource.xml", "Select State");
}

ASP .net interview question

Questions:
Please write a sample program that parses the string into a series of substrings where the delimiter between the substrings is "^*!%~" and then reassembles the strings and delimiters into a single new string where each of the substrings is in the reverse order from the original string. The method must return the final string.

Original String:
Token A^*!%~Token B^*!%~Token C^*!%~Token D^*!%~Token E

Output String:
Token E^*!%~Token D^*!%~Token C^*!%~Token B^*!%~Token A

The code sample below shows how to solve the above question:
using System;
using System.Text;
namespace GenericsSample
{
class Program
{
static void Main()
{
string strOriginalString = "Token A^*!%~Token B^*!%~Token C^*!%~Token D^*!%~Token E";
string[] strSeperator = new string[1];
strSeperator[0] = "^*!%~";

string[] strArrayIndividualStrings = strOriginalString.Split(strSeperator, StringSplitOptions.RemoveEmptyEntries);

int intLengthOfStringArray = strArrayIndividualStrings.Length;

StringBuilder sbOutputString = new StringBuilder();
for (int i = (intLengthOfStringArray - 1); i >= 0; i--)
{
sbOutputString.Append(strArrayIndividualStrings[i] + strSeperator[0]);
}
Console.WriteLine("Original String : " + strOriginalString);
Console.WriteLine("Output String : " + sbOutputString.ToString());
Console.ReadLine();
}
}
}

Explanation of the above sample program:
1.
We take the original string into a string variable strOriginalString. I named this variable as strOriginalString. str indicates that the variable is of string datatype. This will give a good impression to the person who reviews your code bcos you are following the coding standards.

2. I then store the string delimiter "^*!%~" in strSeperator variable. strSeperator is of string array data type. This is bcos the split function expects string array or character array as seprator.

3. I then split the strOriginalString into a string array using the split function.

4. I created a variable sbOutputString to store the Output string. sbOutputString data type is StringBuilder.

5. I then loop thru the array from the highest index to 0 and retrieve the individual strings and append to the sbOutputString. As the output string is changing as we loop thru the array it is good to use StringBuilder rather than System.String. Strings of type System.Text.StringBuilder are mutable where as strings of type System.String are immutable. If a string is manipulated many times always use StringBuilder over System.String.

6. Two good things to remember from this example are, follow the coding standards in naming the variables and always use StringBuilder class over Strings where we manipulate a particular string many times.

Question 2:
The XML file below has a list of employees. Your job is to bind the employee IDs and Names to a dropdownlist. ID must be dropdownlist value field and name must be the dropdownlist Text field. Also, only the active employees must be binded to the dropdownlist and the names should be in the ascending order. When I select a name from the dropdownlist, the name and ID of the selected employee must be printed on the webform.

Employees.xml


David
101
true


Tom
102
true


Rick
103
false


Mark
104
true



Code sample:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet DS = new DataSet();
DS.ReadXml(Server.MapPath("Employees.xml"));

DataView DV = DS.Tables["Employee"].DefaultView;
DV.RowFilter = "IsActive='true'";
DV.Sort = "Name asc";

DropDownList1.DataSource = DV;
DropDownList1.DataValueField = "ID";
DropDownList1.DataTextField = "Name";
DropDownList1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("Name Is : " + DropDownList1.SelectedItem.Text + " and ID is " + DropDownList1.SelectedItem.Value);
}

Code Explanation:
1.
Read the XML data from Employees.xml file into a DataSet. We make use of the ReadXml() method. ReadXml method loads the XML data into the dataset DS. DS.ReadXml(Server.MapPath("Employees.xml"));

2. Now you have the Data in a relational format in the dataset. Create a DataView on the employees table in the DataSet. The DefaultView property of DataTable returns the DataView.
DataView DV = DS.Tables["Employee"].DefaultView;

3. After you have created the DataView, apply the RowFilter, to select only the active employees. You apply the RowFilter as shown below.
DV.RowFilter = "IsActive='true'";

4. Now sort the data in the DataView in ascending order. We sort the data on the Name column. You can apply the sort expression on a dataview as shown below.
DV.Sort = "Name asc";

5. Finally set the DataSource, DataValueField and DataTextField properties of the dropdownlist and call the DataBind() method as shown in the below code.
DropDownList1.DataSource = DV;
DropDownList1.DataValueField = "ID";
DropDownList1.DataTextField = "Name";
DropDownList1.DataBind();


Untill now we have seen how to bind an XML file to dropdownlist. We have also seen how to create a DataView on DataTable. DataView is used for sorting and filtering the data. Now we have to get the SelecteValue and SelectedItem Text of a dropdownlist. To achieve this, follow the below steps.

1. Set the autopostback property of the dropdownlist to true. So, when ever a selection in the dropdownlist changes, the webform is posted back to the server automatically.

2. In the DropDownList1_SelectedIndexChanged event handler we can capture the employee name and id using the DropDownList1.SelectedItem.Text and DropDownList1.SelectedItem.Value properties as shown below.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("Name Is : " + DropDownList1.SelectedItem.Text + " and ID is " + DropDownList1.SelectedItem.Value);
}

Note: If you have noticed, we binded the XML file to the dropdownlist only during the initial page load and not during every post back. We do this check by using if(!IsPostBack) property of the page.

asp .net : Remote and Web service Interview questions

Que:- What is .NET Remoting ?
Ans:- .NET remoting is replacement of DCOM. Using .NET remoting you can make remote
object calls which lie in different Application Domains. As the remote objects run in
different process client calling the remote object can not call it directly. So the client uses
a proxy which looks like a real object.

When client wants to make method call on the remote object it uses proxy for it. These
method calls are called as “Messages”. Messages are serialized using “formatter” class
and sent to client “channel”. Client Channel communicates with Server Channel. Server
Channel uses as formatter to deserialize the message and sends to the remote object.


Que:- Which class does the remote object has to inherit ?
Ans:- All remote objects should inherit from System.MarshalbyRefObject.


Que:- What are two different types of remote object creation mode in .NET ?
Ans:- There are two different ways in which object can be created using Remoting :-
SAO (Server Activated Objects) also called as Well-Known call mode.
CAO (Client Activated Objects)

SAO has two modes “Single Call” and “Singleton”. With Single Call object the object is
created with every method call thus making the object stateless. With Singleton the object
is created only once and the object is shared with all clients.

CAO are stateful as compared to SAO. In CAO the creation request is sent from client
side. Client holds a proxy to the server object created on server.

Que:- Describe in detail Basic of SAO architecture of Remoting?
Ans:-
Remoting has at least three sections :-
* Common Interface which will be shared between them.
* Server.
* Client.

Que:- What are the situations you will use singleton architecture in remoting ?
Ans:- If all remoting clients have to share the same data singleton architecture will be used.

Que:- What are the ways in which client can create object on server in CAO model ?
Ans:- There are two ways by which you can create Client objects on remoting server :
Activator.CreateInstance().
By Keyword “New”

Que:- How can we call methods in remoting Asynchronously ?
Ans:- All previous examples are a synchronous method calls that means client has to wait until
the method completes the process. By using Delegates we can make Asynchronous method
calls.

Que:- What is Asynchronous One-Way Calls ?
Ans:- One-way calls are a different from asynchronous calls from execution angle that the .NET
Framework does not guarantee their execution. In addition, the methods used in this kind
of call cannot have return values or out parameters. One-way calls are defined by using
[OneWay()] attribute in class.

Que:- What is marshalling and what are different kinds of marshalling ?
Ans:- Marshaling is used when an object is converted so that it can be sent across the network
or across application domains. Unmarshaling creates an object from the marshaled data.
There are two ways to do marshalling :-

Marshal-by-value (MBV) :- In this the object is serialized into the channel, and
a copy of the object is created on the other side of the network. The object to
marshal is stored into a stream, and the stream is used to build a copy of the
object on the other side with the unmarshalling sequence.

Marshaling-by-reference (MBR):- Here it creates a proxy on the client that is
used to communicate with the remote object. The marshaling sequence of a
remote object creates an ObjRef instance that itself can be serialized across
the network.

Que:- What is ObjRef object in remoting ?
Ans:- All Marshal() methods return ObjRef object.The ObjRef is serializable because it
implements the interface ISerializable, and can be marshaled by value. The ObjRef knows
about :-
* location of the remote object
* host name
* port number
* object name

MOST IMPORTANT QUESTION

Que:- What is a Web Service ?
Ans:- Web Services are business logic components which provide functionality via the Internet
using standard protocols such as HTTP.
Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business
functionality.SOAP defines a standardized format in XML which can be exchanged
between two entities over standard protocols such as HTTP. SOAP is platform independent
so the consumer of a Web Service is therefore completely shielded from any
implementation details about the platform exposing the Web Service. For the consumer it
is simply a black box of send and receive XML over HTTP. So any web service hosted on
windows can also be consumed by UNIX and LINUX platform.

Que:- What is UDDI ?
Ans:- Full form of UDDI is Universal Description, Discovery and Integration. It is a directory
that can be used to publish and discover public Web Services. If you want to see more
details you can visit the http://www.UDDI.org .


Que:- What is DISCO ?
Ans:- DISCO is the abbreviated form of Discovery. It is basically used to club or group common
services together on a server and provides links to the schema documents of the services
it describes may require.

Que:- What is WSDL?
Ans:- Web Service Description Language (WSDL)is a W3C specification which defines XML
grammar for describing Web Services.XML grammar describes details such as:-
* Where we can find the Web Service (its URI)?
* What are the methods and properties that service supports?
* Data type support.
* Supported protocols

In short its a bible of what the webservice can do.Clients can consume this WSDL and
build proxy objects that clients use to communicate with the Web Services. Full WSDL
specification is available at http://www.w3.org/TR/wsdl.

Que:- What is file extension of Webservices ?
Ans:- .ASMX is extension for Webservices.

Que:-Which attribute is used in order that the method can be used as WebService?
Ans:- WebMethod attribute has to be specified in order that the method and property can be
treated as WebService.

Que:- Do webservice have state ?
Twist :- How can we maintain State in Webservices ?
Ans:-

Webservices as such do not have any mechanism by which they can maintain state.
Webservices can access ASP.NET intrinsic objects like Session, application and so on if
they inherit from “WebService” base class.


Imports System.Web.Services
Public class TestWebServiceClass
Inherits WebService
Public Sub SetSession(value As String)
session("Val") = Value
End Sub
end class

Above is a sample code which sets as session object called as “val”. TestWebserviceClass
is inheriting from WebService to access the session and application objects.

Secret Interview questions related to asp .net framework

Que:- What is a IL?
Ans:-(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language)(Common Intermediate Language). All .NET source code is compiled to IL. This IL is converted to machine code at the point where the software is installed, or at run-time by a Just In Time (JIT) compiler.

Que:- What is a CLR?
Ans: Full form of CLR is Common Language Runtime and it forms the heart of the .NET frame All Languages have runtime and its the responsibility of the runtime to take care of the execution of the program. For example VC++ has MSCRT40.DLL,VB6 has MSVBVM60.Java has Java Virtual Machine etc. Similarly .NET has CLR. Following are the responsibility CLR 

Garbage Collection :- CLR automatically manages memory thus eliminating memory leaks. When objects are not referred GC automatically releases those
memories thus providing efficient memory management.

Code Access Security :- CAS grants rights to program depending on the securi
configuration of the machine. Example the program has rights to edit or creat
a new file but the security configuration of machine does not allow the progra
to delete a file. CAS will take care that the code runs under the environment o
machines security configuration.

Code Verification :- This ensures proper code execution and type safety while
the code runs. It prevents the source code to perform illegal operation such as
accessing invalid memory locations etc.

IL( Intermediate language )-to-native translators and optimizer’s :- CLR uses
JIT and compiles the IL code to machine code and then executes. CLR also
determines depending on platform what is optimized way of running the IL code.


Oue:- What is a CLS(Common Language Specification)?
Ans:- This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.

Que:- What is a Managed Code?
Ans:- Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.

Que:- What is a Assembly?
Ans:- 1)Assembly is unit of deployment like EXE or a DLL.
2)An assembly consists of one or more files (dlls, exe’s, html files etc.), and
represents a group of resources, type definitions, and implementations of those
types. An assembly may also contain references to other assemblies. These
resources, types and references are described in a block of data called a manifest.
The manifest is part of the assembly, thus making the assembly self-describing.
3)An assembly is completely self-describing.An assembly contains metadata
information, which is used by the CLR for everything from type checking and
security to actually invoking the components methods. As all information is in the
assembly itself, it is independent of registry. This is the basic advantage as
compared to COM where the version was stored in registry.


Que:- What are the different types of Assembly?
Ans:- There are two types of assembly Private and Public assembly. A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. Crystal report classes which will be used by all application for
Reports.

Que:- What is NameSpace?
Ans:- Namespace has two basic functionality :-

NameSpace Logically group types, example System.Web.UI logically groups
our UI related features.

In Object Oriented world many times its possible that programmers will use the
same class name.By qualifying NameSpace with classname this collision is able to
be removed.

Que: What is Difference between NameSpace and Assembly?
Ans:- Following are the differences between namespace and assembly :

Assembly is physical grouping of logical units. Namespace logically groups
classes.

Namespace can span multiple assembly.

Que:- What is garbage collection?
Ans:- Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ..... Laziness (Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when
it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.


Que:- What is reflection?
Ans:- All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”.System. Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember. Below is sample source code.

Public Class Form1 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Pobjtype As Type
Dim PobjObject As Object
Dim PobjButtons As New Windows.Forms.Button()
Pobjtype = PobjButtons.GetType()
For Each PobjObject In Pobjtype.GetMembers
LstDisplay.Items.Add(PobjObject.ToString())
Next
End Sub
End Class


Que:- What are Value types and Reference types ?
Ans:- Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure.
Reference types store a reference to the value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer types, or interface types.
Variables that are value types each have their own copy of the data, and therefore operations on
one variable do not affect other variables. Variables that are reference types can refer to the same
object; therefore, operations on one variable can affect the same object referred to by another
variable. All types derive from the System.Object base type.


Most Important Question.

Que:- What is the difference between VB.NET and C# ?
Ans:- Well this is the most debatable issue in .NET community and people treat there languages like religion. Its a subjective matter which language is best. Some like VB.NET’s natural style and some like professional and terse C# syntaxes. Both use the same framework and speed is also very much equivalents. But still let’s list down 

some major differences between them :-

Advantages VB.NET :-

* Has support for optional parameters which makes COM interoperability much easy.
* With Option Strict off late binding is supported.Legacy VB functionalities can be
used by using Microsoft.VisualBasic namespace.
* Has the WITH construct which is not in C#.
* The VB.NET part of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very 
large projects have found that the IDE slows down considerably as the project gets 
larger.

Advantages of C#

* XML documentation is generated from source code but this is now been incorporated
in Whidbey.
* Operator overloading which is not in current VB.NET but is been introduced in
Whidbey.
* Use of this statement makes unmanaged resource disposal simple.
* Access to Unsafe code. This allows pointer arithmetic etc, and can improve
performance in some situations. However, it is not to be used lightly, as a lot of 
the normal safety of C# is lost (as the name implies).This is the major difference 
that you can access unmanaged code in C# and not in VB.NET.

Que:- What is the difference between System exceptions and Application exceptions?
Ans:- All exception derives from Exception Base class. Exceptions can be generated programmatically or can be generated by system. Application Exception serves as the base class for all application- specific exception classes. It derives from Exception but does not provide any extended functionality. You should derive your custom application exceptions from Application Exception. Application exception is used when we want to define user defined exception, while system exception is all which is defined by .NET.

Que:- What is the difference between Convert.toString and .toString()method ?
Ans:- Just to give an understanding of what the above question means seethe below code.

int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));

We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference.
The basic difference between them is “Convert” function handles NULLS while “i.ToString()”
does not it will throw a NULL reference exception error. So as good coding practice using
“convert” is always safe.

ASP .NET Job Interview Questions

Que:- What is the sequence in which ASP.NET events are processed ?
Ans:- Following is the sequence in which the events occur :-
* Page_Init.
* Page_Load.
* Control events.
* Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.

Que:- In which event are the controls fully loaded ?
Ans:- Page_load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that viewstate is not fully loaded during this event.

Que:- How can we identify that the Page is PostBack ?
Ans:- Page object has a “IsPostBack” property which can be checked to know that is the page posted back.

Que:-What is event bubbling ?
Ans:- Server controls like Datagrid, DataList, Repeater can have other child controls inside them. Example DataGrid can have combo box inside datagrid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event. As the child control send there events to parent this is termed as event bubbling.

Que:- If we want to make sure that no one has tampered with ViewState, how do we ensure it?
Ans:- Using the @Page directive EnableViewStateMac to True.

Que:- What is AppSetting Section in “Web.Config” file?
Ans:- Web.config file defines configuration for a webproject. Using “AppSetting” section we can define user defined values. Example below defined is ConnectionString” section which will be used through out the project for database connection.

Que:- Where is ViewState information stored ?
Ans:- In HTML Hidden Fields.

Que:- How can we create custom controls in ASP.NET ?
Ans:- User controls are created using .ASCX in ASP.NET. After .ASCX file is created you need to two things in order that the ASCX can be used in project:

* Register the ASCX control in page using the 
* Now to use the above accounting footer in page you can use the below directive.

Que:- How many types of validation controls are provided by ASP.NET ?
Ans:- There are six main types of validation controls :-
1). RequiredFieldValidator :-

It checks whether the control have any value. It's used when you want the control should not be empty.

2). RangeValidator :- 

It checks if the value in validated control is in that specific range. Example
TxtCustomerCode should not be more than eight length.

3). CompareValidator:-

It checks that the value in controls should match the value in other control. Example
Textbox TxtPie should be equal to 3.14.

4). RegularExpressionValidator:-

When we want the control value should match with a specific regular expression.

5). CustomValidator:-

It is used to define UserDefined validation.

6). ValidationSummary:-

It displays summary of all current validation errors.

Que:- Can you explain what is “AutoPostBack” feature in ASP.NET ?
Ans:- If we want the control to automatically postback in case of any event, we will need to check this attribute as true. Example on a ComboBox change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

Que:- How can you enable automatic paging in DataGrid ?
Ans:- Following are the points to be done in order to enable paging in Datagrid :-
* Set the “AllowPaging” to true.
* In PageIndexChanged event set the current pageindex clicked.

Que:-What is the difference between “Web.config” and “Machine.Config” ?
Ans:- “Web.config” files apply settings to each web application, while Machine.config” file apply settings to all ASP.NET applications.

Que:- What is the difference between Server.Transfer and response.Redirect ?
Ans:- Following are the major differences between them:-
* Response.Redirect sends message to the browser saying it to move to some
different page, while server.transfer does not send any message to the browser
but rather redirects the user directly from the server itself. So in server.transfer
there is no round trip while response.redirect has a round trip and hence puts
a load on server.

* Using Server.Transfer you can not redirect to a different from the server itself.
Example if your server is www.yahoo.com you can use server.transfer to move
to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e.
within websites. This cross server redirect is possible only using
Response.redirect.

* With server.transfer you can preserve your information. It has a parameter
called as “preserveForm”. So the existing query string etc. will be able in the
calling page. In response.redirect you can maintain the state, but has
lot of drawbacks.

Que:- What is the difference between Authentication and authorization?
Ans:- This can be a tricky question. These two concepts seem altogether similar but there is wide range of difference. Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use
the application, it still authenticates them as being anonymous.

Que:- What are the various ways of authentication techniques in ASP.NET?
Ans:- Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:

* authentication mode=”windows”
* authentication mode=”passport”
* authentication mode=”forms”
* Custom authentication where you might install an ISAPI filter in IIS that
compares incoming requests to list of source IP addresses, and considers
requests to be authenticated if they come from an acceptable address. In that
case, you would set the authentication mode to none to prevent any of the
.net authentication providers from being triggered.

Que:- How does authorization work in ASP.NET?
Ans:- ASP.NET impersonation is controlled by entries in the applications web.config file. The default setting is “no impersonation”. You can explicitly specify that ASP.NET shouldn’t use impersonation by including the following code in the file

It means that ASP.NET will not perform any authentication and runs with its own
privileges. By default ASP.NET runs as an unprivileged account named ASPNET. You
can change this by making a setting in the processModel section of the machine.config
file. When you make this setting, it automatically applies to every site on the server. To user a high-privileged system account instead of a low-privileged set the userNameattribute of the processModel element to SYSTEM. Using this setting is a definite security risk, as it elevates the privileges of the ASP.NET process to a point where it can do bad things to the operating system.

Que:- What’s difference between Datagrid, Datalist and repeater ?
Ans:- A Datagrid, Datalist and Repeater are all ASP.NET data Web controls.
They have many things in common like DataSource Property, DataBind Method
ItemDataBound and ItemCreated.
When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow
present in the DataRow Collection of DataTable is assigned to a corresponding
DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Datagrid has an HTML TABLE element created for the particular DataRow and its a Table form representation with Columns and Rows.
For a Datalist its an Array of Rows and based on the Template Selected and the
RepeatColumn Property value We can specify how many DataSource records should
appear per HTML table row. In short in datagrid we have one record per row, but in
datalist we can have five or six rows per row.
For a Repeater Control, the Datarecords to be displayed depends upon the Templates
specified and the only HTML generated is the due to the Templates.
In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data,which is not possible when using a DataList and for a Repeater Control we would require to write an explicit code to do paging.

Que:- From performance point of view how do they rate ?
Ans:- Repeater is fastest followed by Datalist and finally datagrid.

Que:- What is the method to customize columns in DataGrid?
Ans:- Use the template column.

Que:- How can we format data inside DataGrid?
Ans:- Use the DataFormatString property.

Que:- How to decide on the design consideration to take a Datagrid, datalist or repeater ?
Ans:- Many make a blind choice of choosing datagrid directly, but that's not the right way.
Datagrid provides ability to allow the end-user to sort, page, and edit its data. But it comes at a cost of speed. Second the display format is simple that is in row and columns.
Real life scenarios can be more demanding that With its templates, the DataList provides more control over the look and feel of the displayed data than the DataGrid. It offers better performance than datagrid Repeater control allows for complete and total control. With the Repeater, the only HTML emitted are the values of the databinding statements in the templates along with the HTML markup specified in the templates—no "extra" HTML is emitted, as with the DataGrid and DataList. By requiring the developer to specify the complete generated HTML markup, the Repeater often requires the longest development time. But repeater does not provide editing features like datagrid so everything has to be coded by programmer. However, the Repeater does boast the best performance of the three data Web controls.
Repeater is fastest followed by Datalist and finally datagrid.

Que:- Difference between ASP and ASP.NET?
Ans:- ASP.NET new feature supports are as follows :-

Better Language Support

* New ADO.NET Concepts have been implemented.
ASP.NET supports full language (C#, VB.NET, C++) and not simple scripting
like VBSCRIPT..

Better controls than ASP

* ASP.NET covers large set’s of HTML controls..
* Better Display grid like Datagrid, Repeater and datalist.Many of the display
grids have paging support.

Controls have events support

* All ASP.NET controls support events.
* Load, Click and Change events handled by code makes coding much simpler and much better organized.

Compiled Code

The first request for an ASP.NET page on the server will compile the ASP.NET code and
keep a cached copy in memory. The result of this is greatly increased performance.
Better Authentication Support
ASP.NET supports forms-based user authentication, including cookie management and
automatic redirecting of unauthorized logins. (You can still do your custom login page and custom user checking).

User Accounts and Roles

ASP.NET allows for user accounts and roles, to give each user (with a given role) access to different server code and executables.

High Scalability

* Much has been done with ASP.NET to provide greater scalability.
* Server to server communication has been greatly enhanced, making it possible
to scale an application over several servers. One example of this is the ability
to run XML parsers, XSL transformations and even resource hungry session objects on other servers.

Easy Configuration

Configuration of ASP.NET is done with plain text files.
* Configuration files can be uploaded or changed while the application is running.
No need to restart the server. No more metabase or registry puzzle.

Easy Deployment

No more server restart to deploy or replace compiled code. ASP.NET simply redirects all new requests to the new code.


Que:- What are major events in GLOBAL.ASAX file ?
Ans:- The Global.asax file, which is derived from the HttpApplication class, maintains a pool
of HttpApplication objects, and assigns them to applications as needed. The Global.asax
file contains the following events:

Application_Init: Fired when an application initializes or is first called. It is invoked for
all HttpApplication object instances.

Application_Disposed: Fired just before an application is destroyed. This is the ideal
location for cleaning up previously used resources.

Application_Error: Fired when an unhandled exception is encountered within the
application.

Application_Start: Fired when the first instance of the HttpApplication class is created.
It allows you to create objects that are accessible by all HttpApplication instances.
Application_End: Fired when the last instance of an HttpApplication class is destroyed.
It is fired only once during an application's lifetime.

Application_BeginRequest: Fired when an application request is received. It is the first
event fired for a request, which is often a page request (URL) that a user enters.

Application_EndRequest: The last event fired for an application request.

Application_PreRequestHandlerExecute: Fired before the ASP.NET page framework
begins executing an event handler like a page or Web service.

Application_PostRequestHandlerExecute: Fired when the ASP.NET page framework has finished executing an event handler

Applcation_PreSendRequestHeaders: Fired before the ASP.NET page framework sends
HTTP headers to a requesting client (browser).

Application_UpdateRequestCache: Fired when the ASP.NET page framework completes
handler execution to allow caching modules to store responses to be used to handle
subsequent requests.

Application_AuthenticateRequest: Fired when the security module has established the
current user's identity as valid. At this point, the user's credentials have been validated.
Application_AuthorizeRequest: Fired when the security module has verified that a user
can access resources.

Session_Start: Fired when a new user visits the application Web site.

Session_End: Fired when a user's session times out, ends, or they leave the application
Web site.

Que:- What order they are triggered ?
Ans:- They're triggered in the following order:

* Application_BeginRequest
* Application_AuthenticateRequest
* Application_AuthorizeRequest
* Application_ResolveRequestCache
* Application_AcquireRequestState
* Application_PreRequestHandlerExecute
* Application_PreSendRequestHeaders
* Application_PreSendRequestContent
<>
* Application_PostRequestHandlerExecute
* Application_ReleaseRequestState
* Application_UpdateRequestCache
* Application_EndRequest.

Que:- How can we force all the validation control to run ?
Ans:- Page.Validate

Que:- How can we check if all the validation control are valid and proper ?
Ans:- Using the Page.IsValid() property you can check whether all the validation are done.

Que:- Which JavaScript file is referenced for validating the validators at the client side ?
Ans:- WebUIValidation.js javascript file installed at “aspnet_client” root IIS directory is used
to validate the validation controls at the client side

Que:- What is Tracing in ASP.NET ?
Ans:- Tracing allows us to view how the code was executed in detail.

Que:- How do we enable tracing ?
Ans:- 

Que:- How can we kill a user session ?
Ans:- Session.abandon

Que:- How do I send email message from ASP.NET ?
ANs:- ASP.NET provides two namespaces System.WEB.mailmessage classand
System.Web.Mail.Smtpmail class. Just a small homework create a Asp.NET project and
send a email at "Email Adress". Do not Spam.

Que:- Explain the differences between Server-side and Client-side code?
Ans:- Server side code is executed at the server side on IIS in ASP.NET framework, while
client side code is executed on the browser.