Saturday, 29 July 2017

Top 30 Asp.Net Interview Questions And Answer

1.  What is Asp.Net?

ASP.NET stands for Active Server Pages .ASP.NET was developed in direct response to the problems that developers had with classic ASP. Since ASP is in such wide use. It is not limited to script languages, it allows you to make use of .NET languages like C#, J#, VB, etc. It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). 
Asp.Net runs mainy On Microsoft Visual Studio. Now there is ASP.NET 4.6 version is used in VS2015, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc. IIS can house both ASP and ASP.NET scripts on the same machine.
Read more

2.  Advantages of Asp.Net?


Code seperation from HTML. (Html in aspx and c# code is in aspx.cs page).

Support for compiled language.
Graphical development environment.
State Management.
XML Based Configuration files.
Easy Deployment
Secure for Web Hosting
Easy to Write.   Read more 

3.  Ap.Net Page Life cycle events?
      1) Page_PreInit
      2) Page_Init
      3) Page_InitComplete
      4) Page_PreLoad
      5) Page_Load
      6) Page_LoadComplete
      7) Page_PreRender
      8)Render

4.  Is ViewState data maintained between postback on Single Page?
      Yes data always maintained between single page postback. But if page reditrected to other page then ViewState data will be lost.

5.  Where the viewstate is stored after the page postback?
     ViewState is stored in a hidden field on the page at client side.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

6.  Why Session used in Asp.Net ?
      Session is used to maintain the data between redirection of pages. Session data not lost until we will not  clear the session data. More about Session

7.  What is caching?
     Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.

8.  Types of  caching?
     ASP.NET has 3 kinds of caching :
     Output Caching,
     Fragment Caching,
     Data Caching.

9.  How many types of Validators in Asp.Net?
     (i) Required field Validator
    (ii)Range  Validator
   (iii)Compare Validator
   (iv)Custom Validator
    (v)Regular expression Validator
   (vi)Summary Validator

10.  Which validator you use if you nees to compare two different controls value?

      Compare Validator Control.

11.  Good practice of validation on aspx page?
    We need to use Client side validation for better performance of our web application. It reduces network  traffic  . 

12.  Is it possible to run a WebApplication without Wb.config ?
      Yes.

13.  Can we prevent the browser from caching? If yes then how?
      We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:
Response.Cache.SetNoStore();
Response.Write(DateTime.Now.ToLongTimeString());

14.  In which event control fully loaded?

       PageLoad Event

15. Difference between Response.Write() and Response.Output.Write()?
      Both are used to print the output on the screen. Response.write() is used to display the normal text and Response.output.write() is used to display the formated text.
Response.Output.Write("hello {0}", "asp.net"); //Correct
Response.Write("hello {0}", "asp.net");  //Wrong - Compile time Error

16. When during the page processing cycle is ViewState available?
     After the Init() and before the Page_Load() or On_Load() for a control.

17. What DataType the Range Validator Control Supports
     Range validaor supports integer, Double, Currency , Date and String.

18. What is Server side and client side code meaning?
      Client side code excutes on client machine while server side code excuted on the server.

19. Different types of cookies in Asp.Net ?
       Cookies are two types . Non- Persistent or Session cookies and Persistent cookie.
Session Cookie are those which reside on the client machine for a single session until the user does not logout.
Persistent Cookie are resides on clients machine for a specified period of time. Such as 1 day, 10 days, 1 month etc . You can set the time for the persistent cookies

20. File extension of Web Service?
       Web Service  have .asmx file extension.

21. File extension of User Control?
      User control have .ascx file extension .
       
22. Define Remoting in Asp.net?
       Remoting is a means by which one operating system process, or program, can communicate with another process. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet.

23. What is Global.Asax file in Asp.net?
      It allows to executing ASP.NET application level events and setting application-level variables.

24. Session and Application object e in Asp.net?
      Session object store information between HTTP requests for a particular user.
     Session variables are used to store user specific information where as in application variables we can’t store user specific information.
while application object are global across users.

25. List all templates of the Repeater control?
      ItemTemplate
      AlternatingltemTemplate
      SeparatorTemplate 
      HeaderTemplate
      FooterTemplate

25. List all major built in objects in Asp.net? 
       Application
       Request
       Response
       Server
       Session
       Context
       Trace

26. What is the appSetting section in web.config file in Asp.net?
     The appSettings block in web config file sets the user-defined values for the whole application.
For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:
<configuration>
<appSettings>
<add key="ConnectionString" value="server=local; pwd=password; database=default" />
</appSettings>
</configuration>

26. What is QueryString in Asp.Net?
      A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET, a Query String is Easy to use and the Query String follows a separating character, usually a Question Mark (?). A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET, a Query String is Easy to use and the Query String follows a separating character, usually a Question Mark (?). 
Response.Redirect("Default2.aspx?Ud="+txtUId.Text+"&UserName="+txtUName.Text);

27. List of Data Bind controls in Asp.net?
      Repeater Control
      DataGrid Control
      DataList Control
      GridView Control
      DetailsView
      FormView
      DropDownList
      ListBox
      RadioButtonList
     CheckBoxList
     BulletList etc.

28. What is Authentication and Authorization in Asp.net?
      Authentication: Identify or validate the user.
     Authorization: process of granting approval or permission on resources. Read more

29. What is ConnectionPool? 
       A connection pool is a ‘collection of connections’ which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused. Read more .

30. What is Global Assembly Cache (GAC)?
      GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).

No comments:

Post a Comment