Thursday, 30 October 2014

HCL Asp.Net Interview


           Difference between Client-side and Server-side code.

Client-side code:-

1)     It is a scripting language that can be included in the HTML Page or can contain in the   Source File either .vb or .cs and it is executed in the Browser.
2)     Client side code validates the data before sending it to server.
3)     It is used in validations and faster than server side code.

      Server-side code:-

1)     It is written in the .CS file for C# and .vb file for VB.Net and the Code is executed in the Server side.
2)     Server side code validates the data to check whether sent data is correct or not.
3)     Performance is lower than client side code due to server round trips.
4)     Client cannot see the business logic though it is stored on server.


Difference between String and String Builder:-

  • String is Immutable i.e. not allowed to change the value of an object.(cannot alter)

  • String Builder is Mutable which is allowed to change the value of an object. And it is used when there are complex manipulations have to be done. (Can alter many times).

Difference between Server. Transfer and Response. Redirect:-

  • Server. Transfer is used when redirecting the web page within the same application.
             In this browsers history is not updated. The URL is not changed. Can be used only for .aspx
             pages. No Round trip.
  • Response. Redirect is applicable towards the redirection of the web page between 2 applications. Browsers history is updated. The URL is changed. Can be used for both .aspx and html pages. It provides a Round trip.


Difference between cookies and session:-

  1) Cookies stored in the client side. We can store only strings.

Types of cookies:-

             a) Persistent Cookie:
·         Also called as Permanent Cookie.
·         A cookie that is stored on a user’s hard drive until it expires r delete the cookie.
             b) Session Cookie (in memory):

·         Also called as Temporary Cookie.
·         A Cookie that is available until the browser is active.
                     

   2) Session stores the value in Server side. A session is available as long as browser is opened. We can store the objects also.

       Types of Modes in Session State:-
              
·          InProc mode, which stores session state in memory on the Web server. This is the default.
·          StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
·         SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
·         Custom mode, which enables you to specify a custom storage provider.
·          Off mode

     Difference between Session object and Application Object:-

        Session Object:-

1)     Session object is a memory unique to client.
2)     Session supports any type of object including own custom data types.

Application Object:-

1)     Application object is a memory common to all the clients within a website.
2)     Application memory will be existing till the application is running under worker process.

    Difference between Web user control and Web Custom control

         Web User Control:-
1)     Easier to create.
2)     Limited support for consumers who use a visual design tool.
3)     A separate copy of the control is required in each application.
4)     Cannot be added to the toolbox in visual studio.
5)     Good for static layout.

Used: For different applications.

Web Custom Control:-
      1)Harder to create.
      2)Full visual design tool support for consumers.
      3)Only a singlt copy of the control is required,in the global assembly cache.
      4)Can be added to the toolbox in visual studio.

  Used: For same website

How to Deploy an ASP.net web application? 
  
   After creating and testing your ASP.NET application, the next step is to deploy the application.
   Deployment is the process of distributing the finished application to be installed on other
   Computer.

 You can deploy an ASP.NET Web application using any one of the following
 Three deployment options:      

1.     XCOPY Deployment
2.     Using the Copy Project option in VS .NET
3.     Deployment using VS.NET installer

Difference between Web.config and Machine.config:-

  Web.Config:
     1) This is automatically created when you create an ASP.Net web application project.
     2) This is also called application level configuration file.
     3) This file inherits setting from the machine.config.
     4) Web.config is particular Web Application Specific, it has 
diff web.config files for different applications.
                              
    Machine.Config:

        1) This is automatically installed when you install Visual Studio.Net.
         2) This is also called machine level configuration file.
         3) Only one machine.config file exists on a server.
        4) This file is at the highest level in the configuration hierarchy.

Difference between Array list and Hash table:-

1)     Array list Provides collection similar to an array, but that grows dynamically as the number of elements change. The search for an item in an array list is performed sequentially so it is slow. Type of access is indexed.(sequential access)

2) Hash table is a collection of key-value pairs implemented by hash algorithm. They are big and fast. Type of access is using the hash of a key value. (Random access)

 What are the events fired while loading Grid view?

     1)GridView1_Init
     2)GridView1_RowCreated
     3)GridView1_RowDataBound
     4)GridView1_Load
     5)GridView1_PreRender
     6)GridView1_Unload
   
AutoEventWireup:
          
·         Indicates whether the page's events are automatically enabled
·         If Autoeventwireup=”True”, the ASP.Net runtime does not require events to specify
       Event handlers like Page Load etc.
·         If AutoEventwireup=”false”, manually we have to map the functions to the particular event.

Page. Load+=new Event Handler (this.page_Load)

ADO.NET
Difference between Dataset and Data Reader:-

·         Dataset works on Disconnected Architecture.
·         All type of operations (update, delete etc) can be done through Dataset. Dataset maintains the original data and the modified data separately which requires more space.
·         Low performance. Changes to the Dataset can be propagated back to the data source from where the data originated. Any changes made are applicable on local database and then original database using Data Adapter.

Used:  To maintain relationships between multiple tables and used when there are more no. of operations (insert, update, delete).
Example: Display information in websites from Database.


  • Data Reader works on connected Architecture.
  • Data Reader is Forward-only, Read-only. No local storage is required.
  • Better performance. Data Reader support access to multiple Result sets, but only one at a time. The data is no longer available once the connection to the data source of Data Reader is closed. Can access one table at time. Changes are directly made to the database.

Used: When fewer operations are required.
Example: Display current price in Stock Market, Booking a berth in Railways.

Difference between Copy and Clone:-

  • Clone will copy the structure of the Data. Creates another reference to the same location.

  • Copy will copy the complete structure as well as the Data. Creates two different references to the two different address spaces.

ExecuteNonQuery ():

·         Executes a sqlcommand that executes a SQL statement or stored procedure
·         This doesn’t return a result set.
·         ExecuteNonQuery () is used to upload or insert data into the database.
·         It returns int value.

Execute Reader ():

·         Used to execute sql statements like select which will return result set and result set is accessed by using data readers.
·         Execute Reader() is used for Retrieving data from the database.(Forward only –only retrieval of records)
·         It is used when SELECT command returns more than one value.

Execute Scalar ():
·         Executes the Query and returns the first column of the first row in the result set returned by the query
·         Retrieves a single value from Aggregate functions like sum, count etc.

  1. Create registration page (userid, password, email (unique) and phone number.).
  2. Create login page.
  3. Create forget password page. (here user need to enter email to receive password)
Password should receive to email.
  1. Gridview bind from database.
  2. Gridview edit, delete and update.
  3. Query string, session and cookies.
  4. Search features.
  5. Bind data in to dropdown from database.
  6. Provide the connection details in the web.config