Sunday, 1 September 2013

60+ ASP.NET Interview Questions

1. What is .NET?
Ans. .Net is the platform which provides the web-enabled interface to the internet users for applications and computing devices.

2. What is Asp.net?
Ans. Asp.net is Microsoft's technology for building websites. It's part of the Microsoft .net framework. There are various page extensions provided by Microsoft is being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

3. What is .Net Framework?
Ans. .Net Framework consists of :
- The Framework Class Library
- CLR (Common Language Runtime)
- CLS (Common Language Specification)
- JIT (just in Time Compiler)

4. What is CLR?
Ans. CLR stands for "Common Language Runtime", It is a component of the .Net framework where all programs using .Net technologies are executed.

5. What is Framework Class Library?
Ans. Class Library contains inbuilt functionalities like classes, namespaces, assemblies, etc.

6. What is CLS?
Ans. CLS stands for "Common Language Specification". CLR consists of a set of rules followed by all the languages of the .Net framework. Set of rules is known as Common Language Specification.

7. What is JIT?
Ans. JIT stands for "Just in Time Compiler" It Converts Intermediate language to machine language.

8. What is MSIL?
Ans. MSIL stands for "Microsoft Intermediate Language". All the .Net languages are compiled into another lower-level language. This language is called MSIL. This IL is converted into machine language during execution by JIT. MSIL is Platform independent language.

9. What is namespace?
Ans. The namespace contains classes.

10. What is Assembly?
Ans. Assembly is a set of namespaces that is compiled code. Assembly files have .exe/.dll extension.

11. What is the difference between a namespace and an assembly name?
Ans. The namespace contains classes while assembly contains namespaces.

12. What are the different List controls in asp.net?
Ans. ListBox , DropDownList ,RadioButtonList , CheckBoxList.

13. What are the different Validation controls in asp.net?
Ans. Required field Validator
Range Validator
Compare Validator
Custom Validator
Regular expression Validator
Summary Validator

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

15. Which data type does the RangeValidator control support?
Ans. The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.

16. In which event controls are fully loaded?
Ans. Page load event.

17. What is the difference between a HyperLink control and a LinkButton control?
Ans. A HyperLink control does not have the Click and Command events means it does not submit a form to the server; whereas, the LinkButton control has these events, which can be handled in the code-behind file of the Web page. which enables you to post a form to the server.

18. From which base class all Web Forms are inherited?
Ans. Page class.

19. Which validation control is used when you need to make sure that values in two different controls matched?
Ans. Compare Validator control.

20. What is ViewState?
Ans. ViewState is used to retain the state of server-side objects between page postbacks.its information is maintained in the hidden field and automatically returned to the server with every postback. Viewstate value is used within a single page.

21. Where the ViewState is stored after the page postback?
Ans. ViewState is stored in a hidden field on the page at the client side.

22. How long the items in ViewState exists?
Ans. During the life of the current page.

23. In which event of page cycle is the ViewState available?
Ans. After the Init() and before the Page_Load().

24. What is the Difference between ASP and Asp.net?
Ans.
1. ASP uses the Top-Down Execution Programming model while Asp. net uses Event-Driven Execution Model.
2. ASP uses limited languages while Asp.net supports 44 languages.

25. How many languages .NET is supporting now?
Ans. 44

26. Tell me ASP.NET versions list?
Ans. 1.0,1.1,2.0,3.0,3.5,4.0,4.5

27. What is the advantage of storing an XML file in the applications App_Data folder?
Ans. The contents of the App_Data folder cannot be accessed through the browser.

28. How to avoid Script Injection attacks?
Ans. By encoding user input with HtmlEncode methods.

29. Is it possible to encrypt view state data of an aspx page?
Ans. Yes,
<configuration>
<system.web>
<machineKey validation="3DES" />
</system.web>
</configuration>
<%@Page ViewStateEncryptionMode="Always" %>

30. What are Cookies in ASP.NET?
Ans.
Cookies stores data of visitors.
There are two types of cookies
1. Persistence Cookies
2. Non- Persistence Cookies

31. Explain Persistent cookies.
Ans. Persistent cookies: These can be called permanent cookies, which are stored in the clients hard-drive until they expire. Persistent cookies can be set with an expiration date. Sometimes that stays until the user deletes the cookies.

32. Explain Non-persistent Cookies.
Ans. Non-persistent Cookies: These can be called temporary Cookies. If there is no expiration time defined, then the cookie is stored in the browser memory.

33. How to secure connection strings in an ASP.NET web application?
Ans. By writing connection strings inside the web.config file.user can not access web.config file.

34. What is the work of navigation controls in asp.net?
Ans. Navigation controls are :
SiteMapPath
Menu
TreeView
These controls help us to navigate the website easily.

35. What’s the use of Response.Output.Write()?
Ans. formatted output can be written using Response.Output.Write().

36. What is the difference between the Response.Write() and Response.Output.Write() methods?
Ans. The Response.Write() method allows us to write the normal output; while the Response.Output.Write() method allows us to write the formatted output.

37. What is the difference between Server.Transfer and Response.Redirect?
Ans. Server. Transfer is used to Redirect the page in the same website. Response.Redirect is used to redirect the page to another page or another website.

38. Can we have a web application running without web.Config file?
Ans. Yes, we can run an asp.net application without the WEB.CONFIG file. It means that the default configuration will be loaded from MACHINE.CONFIG file.

39. Can we use multiple web config files for an asp.net application?
Ans. Yes

40. What is the difference between web.config and machine.config File?
Ans. Web.config file is used within web application whereas machine.config file is used in a machine or server. A web application can have more than one web.config file while the server can have only one machin.config file.

41. How can we identify that the Page is Post Back?
Ans. Page.IsPostBack property is used to identify that the page is posted back.

42. What is AutoPostBack?
Ans. AutoPostBack property allows control to postback automatically when an event is raised.

43. Which events can be write in Global.asax?
Ans. Application_Error
Application_Start
Application_End
Session_Start
Session_End

44. What is the file extension of web service?
Ans. .asmx

45. Describe Page Life Cycle Events.
Ans. Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender
Page_UnLoad

46. Which protocol is used to call a Web service?
Ans. HTTP Protocol

47. Which Events are fired when a page loads?
Ans.Init();
LoadViewState()
LoadPostData()
Load()
PreRender()
Render()
Unload()

48. What do you mean by page render?
Ans. Page render means all the asp.net controls are converted to html controls.

49. What is the difference between the content page and the master page?
Ans. Content page inherits master page code while the master page has full html code inside the file.

50. Which is the parent class of the Web server control?
Ans.System.Web.Ul.Control

51. What is the difference between .ToString() method and Convert.ToString() method?
Ans. Convert.ToString() method handles NULL value while .ToString() method will throw NULL reference exception error.

52. What is the difference between System.StringBuilder and System.String?
Ans. System.String is immutable and System.StringBuilder is a mutable. means in StringBuilder we can Append the string to the current value but in System.String we can not append string.

53. Which method is used to explicitly Kill Users Session?
Ans. Session.Abandon();

54. What is the default timeout for a Session?
Ans. 20 minutes

55. What is the default timeout for a cookie?
Ans. 30 minutes

56. What is Machine.config file?
Ans. Machine.config file is a configuration file which retains inside the server. The server can have only one machine.config file.

57. What is the use of the <sessionState> tag in the web.config file?
Ans. This tag is used to set the session state features like session timeout. <sessionState timeout="30"/>

58. How to write connection string in web.config file?
Ans.
<connectionStrings>
<add name="conn"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hatesite.mdf;Integrated Security=True;User Instance=True" />
</connectionStrings>

59. What is Boxing and Unboxing?
Ans. Boxing is an implicit conversion of a value type to the type object. Unboxing in reverse of boxing its a conversion of an object to a value.
For Example
int a=54;
object b=a; //Boxing

int c=(int)b; //Unboxing

60. What is Serialization?

Ans. Serialization is the process of converting an object to a stream of bytes in order to store the object.
        Example: Converting an object to json/xml. Also, we can exchange data using Serialization by means of webservice.
        System.Runtime.Serialization contains the classes necessary for serializing and deserializing objects.
        System.Xml.Serialization contains the classes necessary for serializing and deserializing XML.
        System.Runtime.Serialization.Formatters.Binary contains the classes necessary for binary serialization and deserialization.
       If you do not want a field within your class to be serializable, apply the NonSerializedAttribute           attribute

61. What is Deserialization?

Ans. Deserialization is the reverse process of Serialization that means converting json/xml to object.

62. Types of Serialization?

Ans. 1. Binary Serialization
        2. XML Serialization
 

3 comments:

Thanks

SQL server tricky questions