Basic .NET and ASP.NET interview questions

Submitter said questions were asked in a US company hiring a Web developer.

  1. Explain the .NET architecture.
  2. How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
  3. How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
  4. How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
  5. Resource Files: How to use the resource files, how to know which language to use?
  6. What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
  7. What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
  8. Explain the life cycle of an ASP .NET page.
  9. How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
  10. Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
  11. How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
  12. What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.
This entry was posted in .NET, Web dev. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

43 Comments on Basic .NET and ASP.NET interview questions

  1. Avinash GJ
    Posted 3/31/2005 at 7:44 am | Permalink

    I want a detailed answer for the question.

    1)Explain the life cycle of an ASP .NET page.
    2)Explain the .NET architecture.

  2. Elango Kumar
    Posted 4/5/2005 at 11:38 pm | Permalink

    When a page request is sent to the Web server, whether through a submission or location change, the page is run through a series of events during its creation and disposal. When we try to build ASP.NET pages and this execution cycle is not taken into account, we can cause a lot of headaches for ourselves. However, when used and manipulated correctly, a page’s execution cycle can be an effective and powerful tool. Many developers are realizing that understanding what happens and when it happens is crucial to effectively writing ASP.NET pages or user controls. So let’s examine in detail the ten events of an ASP.NET page, from creation to disposal. We will also see how to tap into these events to implant our own custom code.

    I’ll set the stage with a simple submission form written in ASP.NET with C#. The page is loaded for the first time and has several server-side Web controls on it. When the Web server receives a request for the page, it will process our Web controls and we will eventually get rendered HTML. The first step in processing our page is object initialization.

    Download source code
    View demo

    1. Object Initialization

    A page’s controls (and the page itself) are first initialized in their raw form. By declaring your objects within the constructor of your C# code-behind file (see Figure 1), the page knows what types of objects and how many to create. Once you have declared your objects within your constructor, you may then access them from any sub class, method, event, or property. However, if any of your objects are controls specified within your ASPX file, at this point the controls have no attributes or properties. It is dangerous to access them through code, as there is no guarantee of what order the control instances will be created (if they are created at all). The initialization event can be overridden using the OnInit method.

    Figure 1 - Controls are initialized based on their declaration.

    2. Load Viewstate Data

    After the Init event, controls can be referenced using their IDs only (no DOM is established yet for relative references). At LoadViewState event, the initialized controls receive their first properties: viewstate information that was persisted back to the server on the last submission. The page viewstate is managed by ASP.NET and is used to persist information over a page roundtrip to the server. Viewstate information is saved as a string of name/value pairs and contains information such as control text or value. The viewstate is held in the value property of a hidden control that is passed from page request to page request. As you can see, this is a giant leap forward from the old ASP 3.0 techniques of maintaining state. This event can be overridden using the LoadViewState method and is commonly used to customize the data received by the control at the time it is populated. Figure 2 shows an example of overriding and setting viewstate at the LoadViewState event.

    Figure 2 - When LoadViewState is fired, controls are populated with the appropriate viewstate data.

    3. LoadPostData Processes Postback Data

    During this phase of the page creation, form data that was posted to the server (termed postback data in ASP.NET) is processed against each control that requires it. When a page submits a form, the framework will implement the IPostBackDataHandler interface on each control that submitted data. The page then fires the LoadPostData event and parses through the page to find each control that implements this interface and updates the control state with the correct postback data. ASP.NET updates the correct control by matching the control’s unique ID with the name/value pair in the NameValueCollection. This is one reason that ASP.NET requires unique IDs for each control on any given page. Extra steps are taken by the framework to ensure each ID is unique in situations, such as several custom user controls existing on a single page. After the LoadPostData event triggers, the RaisePostDataChanged event is free to execute (see below).

    4. Object Load

    Objects take true form during the Load event. All object are first arranged in the page DOM (called the Control Tree in ASP.NET) and can be referenced easily through code or relative position (crawling the DOM). Objects are then free to retrieve the client-side properties set in the HTML, such as width, value, or visibility. During Load, coded logic, such as arithmetic, setting control properties programmatically, and using the StringBuilder to assemble a string for output, is also executed. This stage is where the majority of work happens. The Load event can be overridden by calling OnLoad as shown in Figure 3.

    Figure 3 - The OnLoad event is an ideal location to place logic.

    5. Raise PostBack Change Events

    As stated earlier, this occurs after all controls that implement the IPostBackDataHandler interface have been updated with the correct postback data. During this operation, each control is flagged with a Boolean on whether its data was actually changed or remains the same since the previous submit. ASP.NET then sweeps through the page looking for flags indicating that any object’s data has been updated and fires RaisePostDataChanged. The RaisePostDataChanged event does not fire until all controls are updated and after the Load event has occurred. This ensures data in another control is not manually altered during the RaisePostDataChanged event before it is updated with postback data.

    6. Process Client-Side PostBack Event

    After the server-side events fire on data that was changed due to postback updates, the object which caused the postback is handled at the RaisePostBackEvent event. The offending object is usually a control that posted the page back to the server due to a state change (with autopostback enabled) or a form submit button that was clicked. There is often code that will execute in this event, as this is an ideal location to handle event-driven logic. The RaisePostBackEvent event fires last in the series of postback events due to the accuracy of the data that is rendered to the browser.

    Controls that are changed during postback should not be updated after the executing function is called due to the consistency factor. That is, data that is changed by an anticipated event should always be reflected in the resulting page. The RaisePostBackEvent can be trapped by catching RaisePostBackEvent, as in Figure 4.

    Figure 4 - The RaisePostDataChanged and RaisePostBackEvent events are defined by the IPostBackDataHandler interface.

    7. Prerender the Objects

    The point at which the objects are prerendered is the last time changes to the objects can be saved or persisted to viewstate. This makes the PreRender step a good place to make final modifications, such as changing properties of controls or changing Control Tree structure, without having to worry about ASP.NET making changes to objects based off of database calls or viewstate updates. After the PreRender phase those changes to objects are locked in and can no longer be saved to the page viewstate. The PreRender step can be overridden using OnPreRender

    8. ViewState Saved

    The viewstate is saved after all changes to the page objects have occurred. Object state data is persisted in the hidden object and this is also where object state data is prepared to be rendered to HTML. At the SaveViewState event, values can be saved to the ViewState object, but changes to page controls are not. You can override this step by using SaveViewState, as shown in Figure 5.

    Figure 5 - Values are set for controls in OnPreRender. During the SaveViewState event, values are set for the ViewState object.

    9. Render To HTML

    The Render event commences the building of the page by assembling the HTML for output to the browser. During the Render event, the page calls on the objects to render themselves into HTML. The page then collects the HTML for delivery. When the Render event is overridden, the developer can write custom HTML to the browser that nullifies all the HTML the page has created thus far. The Render method takes an HtmlTextWriter object as a parameter and uses that to output HTML to be streamed to the browser. Changes can still be made at this point, but they are reflected to the client only. The Render event can be overridden, as shown in Figure 6 (below).

    10. Disposal

    After the page’s HTML is rendered, the objects are disposed of. During the Dispose event, you should destroy any objects or references you have created in building the page. At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object. You can override Dispose, as shown in Figure 6.

    Figure 6 - The Render event will output custom HTML to the browser through the HtmlTextWriter object.


    Each time we request an ASP.NET page, we run through the same process from initialization to disposal. By understanding the inner workings of the ASP.NET page process, writing and debugging our code will be much easier and effective (not to mention less frustrating).

  3. murali
    Posted 4/7/2005 at 6:31 pm | Permalink

    I want a detailed answer for the question.

    1)Explain the life cycle of an ASP .NET page.
    2)Explain the .NET architecture.

    1) what r object oriented concepts?

    2)how do u create multiple inheritance in c# and .net?

    3)When web.config is called

    4)how many weg.configs a application can have

    5)how do u set language in weg.config

    6)what does connection string consists of

    7)where do u store connection string

    8)what is abstract class?

    9)what is diff b/w interface inhertance and class inheritance

    10)what are the collection classes

    11)what are the types of thrading models?

    12)what inheritance support

    13)what is runtime host?


    15)optimization technique description

    16)diff b/w application and session

    17)what is web application virtual directory?

    18)diff b/w Active.exe and Dll

    19)connection pooling in MTS?

    20)if cookies is disabled in client browser will session work

    21)how do u make your site SSL enabled

    22)did u work an IIS adminstration

    23)the following code execute successfully
    response.write(“value of i=”+i);

    24)what are the provides available with

    25)what is a Process,Sesion and Cookie.

    26)what are Abstrat base classes?

    27)what r the diff b/w bstract base classes and Abstrat classes

    28)what r interface in .net?

    29)how is Polymorphism supports in .net?

    30)what r the 2 types of polymorphism supports in .net?

    31)types of compatibilities and explain them

    what is aggregative? How can it be implements in .net?


    33)diff b/w COM components and .net components?how to register it

    34)diff b/w early binding and late binding?


    36) life cycle? When request mode

    37)bout ado and its objects

    38)what is side by side execution

    39) what serialization?

    40)about a class access specifiers and method acess specifiers

    41)what diff b/w overloading and overriding ? how can this be .net

    42)about virtual function and then use

    how do u implement inhetance in .net?

    44)if I want to override a method 1 of class A and this class B then how do u declared

    About friend and protected friend

    46)bout multiple and multi_level Inhertance how to a chive in .net?

    47)ALL kind of access specifiers for a class and for methos?

    48)on ODP.NET

    49)what is nonpderterministic finalization?

    50)what is isPostback property?

    51)what is dictionary base class?


    52)how can a class be extended and how is this mechanism difff from that of implementation an interface?

    53) What are indexes .net?

    54)How can indexeses be implemented in .net?

    Posted 4/11/2005 at 1:16 pm | Permalink

    Do you not have any cartagory for ‘C’ PROGRAMING LANGUAGE?

  5. Rohit Kochar
    Posted 4/16/2005 at 12:42 am | Permalink

    hi friends,

    1. Can some body explain me the concept of boxing and unboxing ?? Is this done exlpicitly or is done implicitly???? what is the need of boxing??

    2. What is viewstate in ??? Please explain the concept of
    viewstate??? Is this a property of web page or of server controls?

    3. what is ISpostback method in ?

    4.What is the diffrence between page_init() and page_load() event?? Can we perform something page_init() which is visible to us as a result ????

    Please send me the answers at my email id

  6. karine
    Posted 6/13/2005 at 7:26 am | Permalink

    if you dont know what is an abstract class, why in the hell are you postuling for a job?
    Learn the language first then come to this site.

  7. Elango Kumar
    Posted 6/16/2005 at 8:53 am | Permalink

    Can Any one tell me what is called web service in .net…
    Actuallly I know what it is for but I just want to know in simple description…

  8. Abhay Nawale
    Posted 6/23/2005 at 4:23 am | Permalink

    Mr Murali
    4)how many weg.configs a application can have
    a)We can have more than one web.config file in an application

    For the other details please learn the language first & than visit this site so that before viewing this site u will have a basic idea

  9. Asif
    Posted 8/24/2005 at 11:13 am | Permalink

    Multiple inheritance is not supported as a built in feature in .NET. However just like JAVA we have the option of implementing multiple inheritance using interfaces.An interface can inherit methods and attributes from different classes regardless of their position in the inheritance hierarchy.Furthermore any subclass that IMPLEMENTS an interface has to implement all methods and attribute for the interface.The methods or attributes that are not being used by the class implementing an interface will be declared as abstract methods.In short when a subclass implements an interface it comes into a contract with the the Interface that it will implement all methods and attributes of the interface.

  10. Asif
    Posted 8/24/2005 at 11:35 am | Permalink

    Overloading is a programming language feature through which we can have multiple versions of a single method using different sets of input parameters.For example through overloading we can have two versions of calculatebonus() function for clerks and managers

    Private Function CalculateBonus(mgrid as string,commission as double) as Double
    ‘Code for calculating bonus goes here
    End Function

    Private Function CalculateBonus(clerkid as string) as Double
    ‘Code for calculating bonus goes here
    End Function

    So here we can see that the same function CalculateBonus exists in two different forms.

  11. saranya
    Posted 9/28/2005 at 3:42 am | Permalink

    how many languages should able to combine to write

  12. ashu
    Posted 10/3/2005 at 4:12 am | Permalink

    Explain the life cycle of an ASP .NET page.
    ans) 1)Page_Init

  13. ashu
    Posted 10/3/2005 at 4:13 am | Permalink

    2)how do u create multiple inheritance in c# and .net?
    ans).net does not support multiple inheritance.u can iherit mulitple interfaces but can’t inherit to classes.

  14. ashu
    Posted 10/3/2005 at 4:14 am | Permalink

    4)how many weg.configs a application can have

    ans) can have one web.conifg per project.

  15. ashu
    Posted 10/3/2005 at 4:16 am | Permalink

    5)how do u set language in weg.config
    ans)by globliztion tag

  16. ashu
    Posted 10/3/2005 at 4:19 am | Permalink

    6)what does connection string consists of

    a connection string consists of password,user,server,datasource,Initial Catalog

  17. ashu
    Posted 10/3/2005 at 4:25 am | Permalink

    8)what is abstract class?
    ans) a abstract class just contains the defination of imlemantation but doesnot have any implemantaion.a abstract class can have abstract methods and can be override.

  18. ashu
    Posted 10/3/2005 at 4:27 am | Permalink

    9)what is diff b/w interface inhertance and class inheritance
    ans) multiple interfaces can be inherited but only one class can be inherited.

  19. ashu
    Posted 10/3/2005 at 4:29 am | Permalink

    10)what are the collection classes
    ans) collection classes are inherited from ICollectionbase and contains keys and corresponding values.similar to hashtable.

  20. ashu
    Posted 10/3/2005 at 4:35 am | Permalink

    20)if cookies is disabled in client browser will session work

    ans)no session will not work.

  21. Suresh
    Posted 2/15/2006 at 12:43 pm | Permalink

    Hi, I have installed .NET & trying to open C# with ASP.NET project. But it says “The webserver reported the following error when attempting to create or open the web project located at the following URL: ‘http://localhost/webapplication1. ‘The login request was denied’ “. Could someone please help me how to run ASP.NET projects in my system.

  22. Ankit Goel
    Posted 6/9/2006 at 4:45 am | Permalink

    Answer to Comment 14:
    A .net project can have any number of Web.Config files. Every folder in project can have one Web.Config file and will override the settings of ancestor folder configuration file.


  23. Ankit Goel
    Posted 6/9/2006 at 4:57 am | Permalink

    Answer to Comment 20:
    In .net state can be maintained in 2 ways:
    - In Process State
    - Out Process State.
    if you are saving state as “In Process state” in that scenerio Client Browser cookies should be enabled but in case you are going for “Out Process State” approach, it has nothing got to do with Client Browser settings.

    Let me know in case you need more information.


  24. Posted 6/17/2006 at 10:26 am | Permalink

    interview questions are very useful…i need some interview questions in with c sharp,vb…and also in sql …i need questions with clear answers for it.

  25. David
    Posted 7/4/2006 at 7:08 am | Permalink

    Hi Ankit,

    I want more information on In Process State / Out Process State. How we have to sent In Process State and Out Process State, give me some example.

    Please send a reply to me mail also..


  26. karthi
    Posted 8/9/2006 at 4:42 am | Permalink

    i need repeteadly asking interview point of questions based on

  27. d
    Posted 8/31/2006 at 1:09 pm | Permalink


  28. Anil Sharma
    Posted 10/5/2006 at 5:24 am | Permalink

    hi ,this is Q8,

    so life cycle of ASP.NET pages is


  29. amitava chowdhury
    Posted 10/17/2006 at 4:26 am | Permalink

    hi anil,

    the life cycle of an ASP.NET page is ok. but when i am clicking a button on some page and it is doing some action how will you explain the life cycle of that button? if it is same as the page then where the click event will come and if it is not same then what is it??????? i was asked this by an interviewer????

  30. amitava chowdhury
    Posted 10/17/2006 at 4:30 am | Permalink

    can anyone tell me what is the differences between override and overload?

  31. ravikumar
    Posted 12/19/2006 at 6:13 am | Permalink

    Where does web.config info stored? Will this be stored in the registry?

  32. amol
    Posted 12/20/2006 at 4:23 am | Permalink

    send me answers

    1 Difference between directcast and ctype.

    2 An example of a ctype and directcast.

    3 ctype(123.34,integer) - should it throw an error? Why or why not?

    4 directcast(123.34,integer) - should it throw an error? Why or why not?

    5 Difference between a sub and a function.

    6 Explain manifest & metadata.

    7 Scope of public/private/friend/protected/protected friend.

    8 Different kinds of methods.

    9 Difference between imperative and interrogative code.

    10 Difference between value and reference type.

    11 What are the two kinds of properties.

    12 What is the raise event used for?

    13 Explain constructor.

    14 What is a resource? Provide an example from your recent project.

    15 What is a system lock?

    16 Describe ways of cleaning up objects.

    17 Where does the dispose method lie and how can it be
    used to clean up resources?

    18 How can you clean up objects holding resources from within the code

  33. Niraj kr Rai
    Posted 1/11/2007 at 3:31 am | Permalink

    What is the maximum size of textbox

  34. Anita
    Posted 2/28/2007 at 10:40 pm | Permalink

    The answer for definition of Abstract Class is, it is a class created strictly for inheritance and is declared with MustInherit in the class header. You cannot instantiate objects from an abstract class, only inherit new classes from it.

  35. reshu
    Posted 4/10/2007 at 5:31 am | Permalink

    Explain the life cycle of an ASP .NET page.
    3)load Postback events
    6)page render

  36. Ankit Goel
    Posted 6/1/2007 at 2:16 am | Permalink

    Hi David,

    I would explain Outprocess State first which should automaticaaly clear InProcess state to you:

    2 ways of maintaining Outprocess state, one you can specify the state server in Web.config and your cookies will be saved on that server, other you can give SQL Server address and state will be maintained in database.

    If none of the above method used (but you have cookies option available to your site) then state will be maintained Inprocess.

    Let me know in case you need any further clarification

  37. Ankit Goel
    Posted 6/1/2007 at 2:18 am | Permalink

    @ Ravi Kumar

    Web Config is a file which contains settings for your application. You can check Web.config file in your application main folder. This information is not stored in registry.
    DOT NET framework is a way to have a registry free application

  38. venkatesh
    Posted 6/15/2007 at 6:08 am | Permalink

    2)how do u create multiple inheritance in c# and .net?
    a) does not support multiple inheritence. but u can
    achive through interface

  39. Deepak
    Posted 6/28/2007 at 2:36 pm | Permalink

    1> Can anyone tell me the code to store a file any doc,txt,pdf file in database like SQL server 2005,MYSQL???

    2> we can view a file in java like open it directly writing the file… method in java but how 2 do it in C#?

  40. Deepak kumar
    Posted 8/14/2007 at 10:24 pm | Permalink

    Qns: Can I Installed .Net 003 / .Net 2005 in window98 ?

    pls. answer send my e-mail ID.

  41. Tariq Aziz
    Posted 7/9/2008 at 6:53 am | Permalink

    38. 2> .Net does not support multiple inheritance for this purpose we use interface. interface is a class which works as mulitple inheritance. a single class can be inherited from mulitiple interface.

  42. Tariq Aziz
    Posted 7/9/2008 at 6:57 am | Permalink

    Ans.32.5 A functions must return some value but sub does not retrun any thing.

  43. Tariq Aziz
    Posted 7/9/2008 at 7:11 am | Permalink

    ans. 32. Direct cast occour cast at runtime and ctype occur at complite time. DirectCast is more efficient than Ctype.
    Ctype: Ctype(12.5,Integer)

Post a Comment

Your email is never published nor shared. Required fields are marked *