Pages

Sunday, May 26, 2013

ASP.NET interview questions and answers

1.What is ASP.NET?
Ans:
ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
->ASP.NET provides increased performance by running compiled code.
->In asp.net all the page inherit from "page" class p but c#  "object"/
->In asp.net must of the time IIS server execute.
->In  asp.net micrisoft provide a server is called "asp.net server".

2.How to write code in asp.net.

Ans:
 Name<asp:TextBox ID="name" runat="server"> // for textbox
<asp:Button ID="Button1" runat="server"Text="Submit" /> // for button
state: <asp:DropDownList ID="ddlStates" runat ="server"> // for dropdownlist
     <asp:ListItem>---select state--- </asp:ListItem>
     <asp:ListItem>Odisha</asp:ListItem>
     <asp:ListItem>karnataka</asp:ListItem>
     </asp:DropDownList>
<asp:listBox ID="idname" runat="server" selection mode="multiple"> //for listbox

3. How can we identify that the Page is Post Back?
Ans: Page object has an "IsPostBack" property, which can be checked to know that is the page posted back
4.In which event are the controls fully loaded?
Ans:Page load event guarantees that all controls are fully loaded.

5. Which is the parent class of the Web server control?
Ans:The System.Web.Ul.Control class is the parent class for all Web server controls.

6.What is the code behind feature of ASP.NET?
The code behind feature divides ASP.NET page files into two files where one defines the user interface (.aspx), while the other contains all of the logic or code (.aspx.cs for C# and .aspx.vb for VB.NET). These two files are glued together with page directives like the following line, which ties the page to the specific code behind class.
<%@ Page language="c#" Codebehind="UICode.cs" Inherits="Library.UICode" %>.

7.What is a web.config file? Machine.config? 

The web.config is the basic configuration file for ASP.NET applications. It utilizes an XML format. It is used to define application settings, connection strings, and much more. These files can appear in multiple directories, and they are applied in a top-down approach. 
8.
8. What’s the use of Response.Output.Write()? 
We can write formatted output  using Response.Output.Write().

9. What is the difference between Server.Transfer and Response.Redirect?  
In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser.  This provides a faster response with a little less overhead on the server.  The clients url history list or current url Server does not update in case of Server.Transfer.
Response.Redirect is used to redirect the user’s browser to another page or site.  It performs trip back to the client where the client’s browser is redirected to the new page.  The user’s browser history list is updated to reflect the new address.

10. What are the different Session state management options available in ASP.NET?

 In-Process
 Out-of-Process.

In-Process stores the session in memory on the web server.

Out-of-Process Session state management stores data in an external server.  The external server may be either a SQL Server or a State Server.  All objects stored in session are required to be serializable for Out-of-Process state management.

11.Define authentication and authorization.

Authentication is the process of identifying users. Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication.
Authorization is the process of granting access to those users based on identity. Authorization allowing access of specific resource to user.

12.Which method do you use to redirect the user to another page without performing a round trip to the client?


Ans:

    Server.Transfer  // for outside
    Server.Execute //inside application(main ans)

13. What is the use of PlaceHolder control? Can we see it at runtime?


The PlaceHolder control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. It used only as a container.

14.What are the event handlers that can be included in the Global.asax file?

The Global.asax file contains some of the following important event handlers:

    Application_Error
    Application_Start
    Application_End
    Session_Start
    Session_End

14. How can you dynamically add user controls to a page?


User controls can be dynamically loaded by adding a Web User Control page in the application and adding the control on this page.

15.What events are fired when a page loads?The following events fire when a page loads:

    Init() - Fires when the page is initializing.
    LoadViewState() - Fires when the view state is loading.
    LoadPostData() - Fires when the postback data is processing.
    Load() - Fires when the page is loading.
    PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
    Unload() - Fires when the page is destroying the instances of server controls.

16.What is a web server?

Ans :A web server delivers requested web pages to users who enter the URL in a web browser.


How you can disable session?

Ans: If we set session Mode="off" in web.config, session will be disabled in the application. For this, we need to configure web.config the following way:
<configuration>
  <sessionstate  Mode="off"/>
</configuration>


9).What are Session Events?
Ans: There are two types of session events available in ASP.NET:
Session_Start
Session_End.

What are the components of ADO.NET?

The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.

What are the different types of cookies in ASP.NET?


Session Cookie – Resides on the client machine for a single session until the user does not log out.

Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.

How we can force all the validation controls to run?


The Page.Validate() method is used to force all the validation controls to run and to perform validation.
 

No comments:

Post a Comment