72
1 | Page KnackHook Knowledge Holder [email protected] www.knackhook.com ASP.NET Interview Questions

ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

1 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

ASP.NET Interview Questions

Page 2: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

2 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Table of Contents

1. About .Net? ......................................................................................................... 7

2. About .Net Framework ........................................................................................ 8

3. About Common Language Runtime (CLR) and its Services? ........................................................................................................... 12

4. What is managed code in .Net? ......................................................................... 13

5. What is unmanaged code in .Net? ..................................................................... 14

6. About Common Type System? ........................................................................... 14

7. About Common Language Specification? ........................................................... 14

8. About Framework Class Library?........................................................................ 15

9. About Visual Studio? ......................................................................................... 15

10. About Execution flow of C# Program? ................................................................ 19

11. About ASP.NET? ................................................................................................ 20

12. About ASP.NET Benifits? .................................................................................... 21

13. About ASP.NET Page Execution? ........................................................................ 21

14. What is a round trip? ......................................................................................... 21

15. About base componens of ASP.NET? ................................................................. 21

16. What is an ASP.NET Web Form? ........................................................................ 22

17. What are the advantages of the code-behind feature? ............................................................................................................ 23

18. About ASP.NET Server Controls? ........................................................................ 23

19. Which is the parent class of the Web server control? ............................................................................................................. 28

Page 3: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

3 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

20. Explain the AdRotator Control? ......................................................................... 28

21. Difference between GridView, Datalist and repeater? .......................................................................................................... 30

22. What are the HTML server controls in ASP.NET? ................................................ 33

23. What is difference between a Label control and a Literal control? .................................................................................................. 34

24. What is the difference between a HyperLink control and a LinkButton control? ..................................................................... 35

25. Explain login controls? ....................................................................................... 35

26. In which database is the information, such as membership, role management, profile, and Web parts personalization, stored? ........................................................................... 35

27. About basic difference between ASP and ASP.NET? ........................................... 36

28. About ASP.NET Page Life cycle? ......................................................................... 36

29. In which event are the controls fully loaded? .................................................... 39

30. How can we identify that the Page is Post Back? ............................................... 39

31. What is AutoPostBack? ...................................................................................... 40

32. About ASP.NET Validation Controls? .................................................................. 40

33. Differentiate between client-side and server-side validations in Web pages? ................................................................................. 43

34. Which method is used to force all the validation controls to run? ................................................................................................. 43

35. What is the function of the CustomValidator control? ............................................................................................................. 43

36. Which data type does the RangeValidator control support? ............................................................................................................ 43

37. How do you prevent a validation control from validating data at the client end? ....................................................................... 43

Page 4: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

4 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

38. Can we validate a DropDownList by RequiredFieldValidator? .................................................................................... 44

39. What is cross-page posting in ASP.NET? ............................................................. 45

40. What are navigation controls? How many navigation controls are there in ASP.NET 4.0? ................................................... 46

41. What do you mean by the Web Part controls in ASP.NET? ........................................................................................................... 46

42. List the features of the Chart control? ............................................................... 46

43. What is event bubbling? .................................................................................... 46

44. Explain serialization and deserialization? ........................................................... 49

45. About Page Directives? ...................................................................................... 50

46. How can you register a custom server control to a Web page? ........................................................................................................ 51

47. About Master Pages? ........................................................................................ 51

48. About User Control? .......................................................................................... 52

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

50. How does a content page differ from a master page? ................................................................................................................ 53

51. About ASP.NET State Managment?.................................................................... 53

52. What are the various session state management options provided by ASP.NET? ........................................................................... 58

53. What is Query String? What are its advantages and limitations? ....................................................................................................... 58

54. What is the lifespan for items stored in ViewState? ........................................... 58

55. What is the default timeout for a Cookie? ......................................................... 58

56. Which method has been introduced in ASP.NET 4.0 to redirect a page permanently? ........................................................................ 58

Page 5: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

5 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

57. Which method is used to post a Web page to another Web page? ........................................................................................... 58

58. How can you ensure that no one has tampered with ViewState in a Web page? ......................................................................... 58

59. How many types of Cookies are available in ASP.NET? ........................................................................................................... 59

60. What is the use of the <sessionState> tag in the web.config file? ................................................................................................. 59

61. Which method do you use to kill explicitly a users session? ............................................................................................................. 59

62. Explain the cookie less session and its working? ................................................ 59

63. About ASP.NET Cache Management? ................................................................ 59

64. What is the difference between page-level caching and fragment caching? ...................................................................................... 59

65. Explain the Application and Session objects in ASP.NET? ........................................................................................................... 60

66. About ADO.NET? ............................................................................................... 60

67. Explain the difference between dataset and datareader? ....................................................................................................... 63

68. Transactions in .Net? ......................................................................................... 63

69. What are the ACID Properties? .......................................................................... 63

70. About ASP.NET Globalization and Localization? ................................................. 65

71. How information about the user's locale can be accessed? .......................................................................................................... 65

72. Which namespaces are necessary to create a localized application? ........................................................................................ 65

73. About machine.config vs web.config? ................................................................ 65

74. What is the appSettings Section in the web.config file? ................................................................................................................... 66

Page 6: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

6 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

75. About ASP.NET Security? ................................................................................... 66

76. What are the various ways of authentication techniques in ASP.NET? ..................................................................................... 66

77. Describe how Passport authentication works? .................................................. 67

78. How do you sign out from forms authentication? .............................................. 67

79. What setting must be added in the configuration file to deny a particular user from accessing the secured resources? ............................................................................................ 67

80. What is Role-based security? ............................................................................. 68

81. About ASP.NET Tracing? .................................................................................... 68

82. Why do you use the App_Code folder in ASP.NET? ............................................ 68

83. What is a multilingual Web site? ....................................................................... 68

84. What is IIS? ....................................................................................................... 68

85. Describe the Events in the Life Cycle of a Web Application? ...................................................................................................... 69

86. What are HTTP handlers in ASP.NET? ................................................................ 69

87. What are the events that happen when a client requests an ASP.NET page from IIS server? ........................................................ 69

88. How can you send an email message from an ASP.NET Web page? .......................................................................................... 70

89. What is the difference between the Response.Write() and Response.Output.Write() methods? .......................................................................................................... 70

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

91. What are the navigation ways between pages available in ASP.NET? ........................................................................................ 70

92. What are Merge modules? ................................................................................ 70

93. What is Satellite assembly? ............................................................................... 70

Page 7: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

7 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

94. Define secured sockets layer? ............................................................................ 70

95. What is application domain? ............................................................................. 71

96. Response.Redirect vs Server.Transfer? .............................................................. 71

97. Explain in what order a destructors is called? .................................................... 71

98. Explain Global Assembly Cache? ........................................................................ 71

99. What is side-by-side execution? ........................................................................ 71

100. Define Resource Files? ....................................................................................... 71

101. What is CAS? ..................................................................................................... 71

102. Difference between an EXE and a DLL? .............................................................. 71

103. Describe use of error pages in ASP.NET? ............................................................ 72

104. Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process? .............................................. 72

About .Net? .Net is a software development platform developed by Microsoft.

Using Dot Net we can build multiple applications like

• Console Application: A console application is an application that takes input and displays output

at a command line console with access to three basic data streams: standard input, standard

output and standard error. Ex : CMD Prompt

• Web Applications: A Web Application is an application which is having GUI and accessible

through the internet in web browser (IE, Crome, Firefox and Safari).A Web Application is a

collection of web pages. Ex : www.msn.com

• Windows Applications (Desktop Applications): An application that target to run in Windows OS

is called Windows Application or Desktop Application. Windows Application doesn’t need Web

Browser to run. Ex : Skype

• Windows Services: A service which runs on Windows environment is called a Windows Service:

Ex: Birthday Alarm of windows system.

• Web Services: Web Service is distribution service where we can host web service and able to

consume it in different applications using internet. Ex : Paypal webservice

Page 8: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

8 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

• Mobile Applications: An Application which targets to run on Mobile is called Mobile Application.

Ex : Whats App

• WPF Applications (Windows Presentation Foundation): WPF application is an Windows

Application which have good look and fell(GUI)

• Silverlight Applications: Silverlight application is a web application with good look and feel.

Dot Net Components:

• Dot Net Framework

• ASP.NET

• Visual Studio

About .Net Framework The .NET Framework is an integral Windows component that supports building and running the next generation of applications. It consists of 2 components.

• Common Language Runtime • Framework Class Library

.Net Framework Versions .Net Framework 1.0 in 2002 .Net Framework 1.1 in 2003 .Net Framework 2.0 in 2005 .Net Framework 3.0 in 2006 .Net Framework 3.5 in 2007 .Net Framework 4.0 in 2010 .Net Framework 4.5 in 2012 .Net Framework 4.5.1 in 2013 .Net Framework 1.1 Features:

1. Introduced ASP.NET Mobile Controls 2. The .NET Framework Data Provider for ODBC, which previously was available as a Web

download only, now ships with the .NET Framework under the namespace System.Data.Odbc 3. The .NET Framework version 1.1 supports side-by-side execution. Side-by-side execution is the

ability to store and execute multiple versions of an application or component on the same computer.

If you have some application requiring assembly version 1.2.0.0 to run properly and some of your application requires same file but having version 1.3.0.0 then you can have both assemblies on your

Page 9: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

9 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

computer and at the same time, you can have both running, using different assemblies at runtime :-) Ajax Tool Kit .Net Framework 2.0 Features:

1. The new generation of 64-bit computers enables the creation of applications that can run faster and take advantage of more memory than is available to 32-bit applications

2. The Microsoft .NET Framework 2.0 includes significant enhancements to all areas of ASP.NET, Master pages allow you to create a consistent layout for all the pages in a site, and themes allow you to define a consistent look for controls and static text. To help protect your sites, you can precompile a Web site to produce executable code from source files (both code files and the markup in .aspx pages). You can then deploy the resulting output, which does not include any source information, to a production server.

3. Applications can now access File Transfer Protocol resources using the WebRequest, WebResponse, and WebClient classes.

4. Four Microsoft programming languages explicitly target the .NET Framework: Visual C#, Microsoft C/C++, Visual J#, and Visual Basic.

5. Using the classes in the System.Net.Mail and System.Net.Mime namespaces, applications can send e-mail to one or more recipients. Mail can be sent with alternate views and can include attachments. Sending carbon copies and blind carbon copies is also supported.

6. ClickOnce deployment allows you to deploy self-updating Windows applications that can be installed and run as easily as Web applications. You can deploy Windows client and command-line applications.

.Net Framework 3.0 Features: The .NET Framework version 3.0 was issued solely to include the following technologies in the .NET Framework and in the Windows Software Development Kit (SDK):

• Windows Communication Foundation: Windows Communication Foundation (WCF) is a runtime and a set of APIs for creating systems that send messages between services and clients. The same infrastructure and APIs are used to create applications that communicate with other applications on the same computer system or on a system that resides in another company and is accessed over the Internet. WCF has all features of following distributed technologies: Web Service, Microsoft Message Queuing (MSMQ), Remoting

• Windows Presentation Foundation: Windows Presentation Foundation (WPF) provides developers with a unified programming model for building rich Windows smart client user experiences that incorporate UI, media, and documents.

• Windows Workflow Foundation: Windows Workflow Foundation, a core component of .NET Framework 3.0, provides a programming model, run-time engine, and tools for building workflow applications. A workflow is a discrete series of activities that model the steps involved in a business process.A workflow is created and maintained by the workflow run-time engine. There can be several workflow engines within an application domain, and each workflow engine can support multiple workflows running concurrently. The run-time enables idle workflows to be unloaded from memory, persisted to a store, and reloaded whenever input is received.

• Windows CardSpace: The Internet continues to be increasingly valuable, and yet also faces significant challenges. Online identity theft, fraud, and privacy concerns are rising. Users must track a growing number of accounts and passwords. This burden results in "password fatigue,"

Page 10: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

10 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

and that results in insecure practices, such as reusing the same account names and passwords at many sites. CardSpace is Microsoft's implementation of an Identity Metasystem that enables users to choose from a portfolio of identities that belong to them and use them in contexts where they are accepted, independent of the underlying identity systems where the identities originate and are used. This topic explains the issue and the CardSpace solution in greater detail, and outlines how Windows Communication Foundation (WCF) users can use CardSpace. Many of these issues are rooted in the lack of a widely adopted identity solution for the Internet. Password security mechanism to authenticate and authorize user access. Windows Cardspace has been replaced with Microsoft Passport authentication.

.Net Framework 3.5 Features:

• Language-Integrated Query (LINQ) is a new feature in Visual Studio 2008 and the .NET Framework 3.5. LINQ extends powerful query capabilities to the language syntax of C# and Visual Basic in the form of standard, easily-learned query patterns.

• The most significant advance is improved support for the development of AJAX-enabled Web sites.

• The .NET Framework 3.5 unifies the Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) frameworks so that you can use WF as a way to author WCF services or expose your existing WF workflow as a service. This enables you to create services that can be persisted, can easily transfer data in and out of a workflow, and can enforce application-level protocols.

.Net Framework 3.5 SP1 Features: The .NET Framework Client Profile is a subset of the full .NET Framework that targets client applications. This improves the installation experience on computers that do not already have the .NET Framework installed. .Net Framework 4.0 Features:

• The .NET Framework 4 Client Profile supports more platforms than in previous versions and provides a fast deployment experience for your applications.

• The .NET Framework 4 provides background garbage collection. This feature replaces concurrent garbage collection in previous versions and provides better performance.

• The dynamic language runtime (DLR) is a new runtime environment that adds a set of services for dynamic languages to the CLR. The DLR makes it easier to develop dynamic languages to run on the .NET Framework and to add dynamic features to statically typed languages. To support the DLR, the new System.Dynamic namespace is added to the .NET Framework.

• The Managed Extensibility Framework (MEF) is a new library in the .NET Framework 4 that helps you build extensible and composable applications.

• The .NET Framework 4 introduces a new programming model for writing multithreaded and asynchronous code that greatly simplifies the work of application and library developers. The new model enables developers to write efficient, fine-grained, and scalable parallel code in a natural idiom without having to work directly with threads or the thread pool. The new System.Threading.Tasks namespace and other related types support this new model. Parallel LINQ (PLINQ), which is a parallel implementation of LINQ to Objects, enables similar functionality through declarative syntax.

Page 11: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

11 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

• Web Forms controls, including a new Chart control. • MVC, including new helper methods for views, support for partitioned MVC applications, and

asynchronous controllers. • ADO.NET provides new features for the Entity Framework, including persistence-ignorant

objects, functions in LINQ queries, and customized object layer code generation. .Net Framework 4.5 Features:

• Windows Store apps are designed for specific form factors and leverage the power of the Windows operating system. A subset of the .NET Framework 4.5 is available for building Windows Store apps for Windows by using C# or Visual Basic.

• The Portable Class Library project in Visual Studio 2012 enables you to write and build managed assemblies that work on multiple .NET Framework platforms. Using a Portable Class Library project, you choose the platforms (such as Windows Phone and .NET for Windows Store apps) to target. The available types and members in your project are automatically restricted to the common types and members across these platforms.

• Support for new HTML5 form types. .Net Framework 4.5.1 Features: Debugging Feature Improvements 64-Bit Edit and Continue support in Visual Studio 2013 : in debug mode we can edit and continue the changes. Inspecting Method return value while debugging using Autos Window as well as a pseudo variable $ReturnValue : we can check the result of return value easily. ADO.NET Connection Resiliency :ADO.NET connection recovery has been increased. Application Performance Improvements ASP.NET Application Suspension :We have ablility to suspend the web application when there is no request for that application. On-Demand Large-Object heap compaction :The On-demand large object heap compaction is now supported in .NET framework 4.5.1 to avoid the OutOfMemory exception. Multi-core JIT Improvements : It enhance the launch time of the application 40-50 %

Page 12: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

12 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

About Common Language Runtime (CLR) and its Services?

The common language runtime is the foundation of the .NET Framework. It is responsible for managing

code execution at run time, and provides core services such as compilation, memory management,

thread management, code execution, enforcement of type safety, and code safety verification.

Compilers target the common language runtime, which defines the basic data types available to

application developers. Because it provides a managed environment for code execution, the common

language runtime enhances developer productivity and contributes to the development of robust

applications.

Page 13: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

13 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

• Class loader, which loads classes into CLR.

• MSIL to native code compiles, this converts MSIL code into native code.

• Code manager, this manages the code during execution.

• Memory allocation and Garbage collector, this performs automatic memory management.

• Security engine, this enforces security restrictions as code level security folder level and

machine level security using tools provided by Microsoft .NET and using .NET Framework setting

under control panel.

• Type checker, which enforces strict type checking.(CTS and CLS)

• Thread support, which provides multithreading support to applications.

• Exception manager, which provides a mechanism to handle the run-time exceptions handling.

• Debug engine, which allows developer to debug different types of applications.

• COM marshaler, which allows .NET applications to exchange data with COM applications.

• Base class library support, which provides the classes (types) that the applications need at run

time.

What is managed code in .Net?

The code that runs under the guidance of common language runtime (CLR) is called managed code. The

versioning and registration problem which are formally handled by the windows programming are

solved in .Net with the introduction of managed code. The managed code contains all the versioning and

type information that the CLR use to run the application.

Ex: The code developed by .Net supporting languages like C#.Net, VB.Net, F#.Net etc.

Page 14: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

14 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

What is unmanaged code in .Net?

The code, which is developed outside .NET, Framework is known as unmanaged code.

Applications that do not run under the control of the CLR are said to be unmanaged, and certain

languages such as C++ can be used to write such applications, which, for example, access low - level

functions of the operating system. Background compatibility with code of VB, ASP and COM are

examples of unmanaged code.

Unmanaged code can be unmanaged source code and unmanaged compile code.

Unmanaged code is executed with help of wrapper classes.

Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper).

Wrapper is used to cover difference with the help of CCW and RCW.

About Common Type System?

The common type system defines how types are declared, used, and managed in the runtime, and is

also an important part of the runtime's support for cross-language integration. The common type

system performs the following functions:

Establishes a framework that helps enable cross-language integration, type safety, and high

performance code execution.

Provides an object-oriented model that supports the complete implementation of many programming

languages.

Defines rules that languages must follow, which helps ensure that objects written in different languages

can interact with each other.

About Common Language Specification?

CLS is a set of specifications that all languages and libraries need to follow

This will ensure interoperability between languages

The CLS rules define a subset of the common type system; that is, all the rules that apply to the common

type system apply to the CLS, except where stricter rules are defined in the CLS. The CLS helps enhance

and ensure language interoperability by defining a set of features that developers can rely on to be

available in a wide variety of languages. The CLS also establishes requirements for CLS compliance; these

help you determine whether your managed code conforms to the CLS and to what extent a given tool

supports the development of managed code that uses CLS features.

If your component uses only CLS features in the API that it exposes to other code (including derived

classes), the component is guaranteed to be accessible from any programming language that supports

the CLS. Components that adhere to the CLS rules and use only the features included in the CLS are said

to be CLS-compliant components.

Most of the members defined by types in the .NET Framework class library are CLS-compliant. However,

some types in the class library have one or more members that are not CLS-compliant. These members

Page 15: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

15 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

enable support for language features that are not in the CLS. (Keywords, Interface methods, Accessor

metadata, Event method metadata, FlagsAttribute and Value encodings).

About Framework Class Library?

The .NET Framework class library is a collection of reusable types that tightly integrate with the common

language runtime. The class library is object oriented, providing types from which your own managed

code can derive functionality. This not only makes the .NET Framework types easy to use, but also

reduces the time associated with learning new features of the .NET Framework. In addition, third-party

components can integrate seamlessly with classes in the .NET Framework.

For example, the .NET Framework collection classes implement a set of interfaces that you can use to

develop your own collection classes. Your collection classes will blend seamlessly with the classes in the

.NET Framework.

About Visual Studio?

Visual Studio .NET is a complete set of development tools for building ASP Web applications, XML Web

services, desktop applications, and mobile applications. Visual Basic .NET, Visual C++ .NET, Visual

C# .NET, and Visual J# .NET all use the same integrated development environment (IDE), which allows

them to share tools and facilitates in the creation of mixed-language solutions. In addition, these

languages leverage the functionality of the .NET Framework, which provides access to key technologies

that simplify the development of ASP Web applications and XML Web services.

Visual Studio includes:

A code editor supporting

Page 16: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

16 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

IntelliSense

Code snippets and

Code refactoring.

The integrated debugger works both

As a source-level debugger and

As a machine-level debugger.

Forms designer for building GUI applications,

Class designer,

And other SW tools

Visual Studio 2005:

Development Environment

Code Editing

Projects, Solutions, and Items

Building, Testing, and Deployment

Visual Studio 2008:

DataRepeater Control

Line and Shape Controls

.NET Framework Client Profile Support

ClickOnce Deployment

Language-Integrated Query (LINQ) is a new set of features in Visual Studio 2008 that extend powerful

query capabilities into the language syntax of C# and Visual Basic.

Visual Studio 2010:

Auto-Implemented Properties

Collection Initializers

Implicit Line Continuation

Multiline Lambda Expressions and Subroutines

New Command-Line Option for Specifying a Language Version

Page 17: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

17 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Type Equivalence Support

Dynamic Support

Covariance and Contravariance

Navigate To

Highlighting References

Generate From Usage

IntelliSense Suggestion Mode

Visual Studio 2012:

Designing and building Windows Store apps

Debugging, optimizing, and publishing Windows Store apps

Designing and building Windows Phone apps

Testing, optimizing, and publishing Windows Phone apps

Developing applications and collaborating more effectively as a team

ASP.NET 4.5 Core Services

ASP.NET 4.5 Web Forms

Visual Studio 2013:

Open the Resolve menu when typing it happens once in a while that you haven’t included the

namespace you need at the top of your file. One common example is Trace found in System.Diagnostics.

If you write Trace, Visual Studio suggests TraceMode and other things, but no Trace. To quickly solve

this, type Trace followed by CTRL + SPACE +. And the Resolve menu comes up where you can select to

include using System.Diagnostics; to make Trace available. Very handy.

64 bit Edit and Continue Have we been waiting for this one or what?!? Finally, by using .Net Framework

4.5.1, we can have the same edit and continue for 64 bits as we’ve been able to with 32 bit code for

ages.

Return value inspection To help out the debugging process you can now easily see return values of

functions being used as parameters in other function calls, for example if you nest several functions in

each other.

Just my code this feature tells the debugger to only step through the code you’ve been writing yourself

and ignore frameworks and other code. The system is doing this by looking at open projects, .pbd files

and program optimisations. For .Net Framework, this came before VS 2013, but what’s new now is that

Page 18: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

18 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

it’s available for C++ and JavaScript as well. To enable or disable Just My Code, open Debug -> Options

and Settings -> General and change the value of Enable Just My Code.

Peek a definition It’s now possible to open up a method definition without having to open that specific

file. You can even open up a section located further up/down in your current file without having to leave

the location you are at now. This feature is called Peek Definition and can be accessed through ALT + F12

or by right clicking the method and select Peek Definition. Here is an example where I’m peeking on the

InitializeComponent () method.

CodeMap – Visual Debugging: When you are in Debug mode, clicking this will open a window which

shows the visual representation of the execution flow

Code Lens

You won’t miss noting this feature when using Visual Studio 2013. There will be indicators sitting atop of

every method in the code editor.

About Garbage Collector?

In the common language runtime (CLR), the garbage collector serves as an automatic memory manager. It provides the following benefits:

Enables you to develop your application without having to free memory. Allocates objects on the managed heap efficiently. Reclaims objects that are no longer being used, clears their memory, and keeps the memory

available for future allocations. Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field.

Provides memory safety by making sure that an object cannot use the content of another object.

Conditions for a garbage collection

Garbage collection occurs when one of the following conditions is true:

The system has low physical memory. The memory that is used by allocated objects on the managed heap surpasses an acceptable

threshold. This threshold is continuously adjusted as the process runs. The GC.Collect method is called. In almost all cases, you do not have to call this method,

because the garbage collector runs continuously. This method is primarily used for unique situations and testing.

Generations

Page 19: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

19 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

The heap is organized into generations so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:

Generation 0. This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation. Newly allocated objects form a new generation of objects and are implicitly generation 0 collections, unless they are large objects, in which case they go on the large object heap in a generation 2 collection. Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.

Generation 1. This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.

Generation 2. This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that is live for the duration of the process.

Garbage collections occur on specific generations as conditions warrant. Collecting a generation means collecting objects in that generation and all its younger generations. A generation 2 garbage collection is also known as a full garbage collection, because it reclaims all objects in all generations (that is, all objects in the managed heap).

Survival and promotions

Objects that are not reclaimed in a garbage collection are known as survivors, and are promoted to the next generation. Objects that survive a generation 0 garbage collection are promoted to generation 1; objects that survive a generation 1 garbage collection are promoted to generation 2; and objects that survive a generation 2 garbage collection remain in generation 2.

When the garbage collector detects that the survival rate is high in a generation, it increases the threshold of allocations for that generation, so the next collection gets a substantial size of reclaimed memory. The CLR continually balances two priorities: not letting an application's working set get too big and not letting the garbage collection take too much time.

About Execution flow of C# Program?

Source code written in C# is compiled into an intermediate language (IL) that conforms to the CLI

specification.

If the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL

code to native machine instructions

Page 20: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

20 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

About ASP.NET?

ASP.NET is a unified Web development model that includes the services necessary for you to build

enterprise-class Web applications with a minimum of coding. ASP.NET is part of the .NET Framework,

and when coding ASP.NET applications you have access to classes in the .NET Framework. You can code

your applications in any language compatible with the common language runtime (CLR), including

Microsoft Visual Basic and C#. These languages enable you to develop ASP.NET applications that benefit

from the common language runtime, type safety, inheritance, and so on.

ASP.NET provides services to allow the creation, deployment, and execution of Web

Applications and Web Services

Web Applications are built using Web Forms

Web Forms are designed to make building web-based applications as easy as building Visual

Basic applications

Built on .NET Framework: any .NET programming language can be used (C#, Visual Basic)

Complete object model

Separation of code and UI

Maintains page state

Session management

Caching, Debugging, Extensibility

Page 21: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

21 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

About ASP.NET Benifits?

Separate presentation from code

Object-oriented approach

Component-based development

Event-driven architecture

Code compilation

Extensible architecture

Built-in state management

Many others (data binding, validation, master pages, etc.)

About ASP.NET Page Execution?

ASP.NET applications are executed via a sequence of HTTP requests and HTTP responses Client Web browser request ASPX pages The Web server executes the ASPX page and produce XHTML + CSS + JavaScript response.

The complete request and reponse is called as round trip.

What is a round trip?

The trip of a Web page from the client to the server and then back to the client is known as a round

trip.The complete request and response is called as round trip.

About base componens of ASP.NET?

Web Forms – deliver ASP.NET user interface

Web Control – the smallest part we can use in our Web application (e.g. text box)

"Code behind" – contains the server-side code

Web.config – contains ASP.NET application configuration

Machine.config – contains configuration for all applications on the ASP.NET server

Global.asax – class containing application level event handlers

Page 22: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

22 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

What is an ASP.NET Web Form?

ASP.NET Web forms are designed to use controls and features that are almost as powerful as the ones

used with Windows forms, and so they are called as Web forms. The Web form uses a server-side object

model that allows you to create functional controls, which are executed on the server and are rendered

as HTML on the client.

The attribute, runat="server", associated with a server control indicates that the Web form must be

processed on the server.

A Web form belongs to the System.Web.UI.Page class.

ASP.Net web form has extention as .aspx

It contains two parts designer page which has .aspx and code behind file has extention .aspx.cs

Designer page is responsible for UI elements

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <h1>KnackHook</h1> </div> </form> </body> </html>

Code behind page is responsible for writing server side code to implement business logic.

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //code to implement business logic }

Page 23: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

23 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

} }

What are the advantages of the code-behind feature?

The code-behind feature of ASP.NET offers a number of advantages:

• Makes code easy to understand and debug by separating application logic from HTML tags

• Provides the isolation of effort between graphic designers and software engineers

• Removes the problems of browser incompatibility by providing code files to exist on the Web server

and supporting Web pages to be compiled on demand.

About ASP.NET Server Controls?

Standard Controls

Data Controls

Validation Controls

Navigation Controls

Login Controls

Web Parts Controls

AJAX Extension Controls

Dynamic Data Controls

Reporting Controls

Standard Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Helps to display textbox to get input from user--%> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <%--Helps to place plain text on the browser window--%> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <%--Helps to submit form to the server and perform business logic based on user interaction--%> <asp:Button ID="Button1" runat="server" Text="Button" /> <%--Helps to select date from the control--%>

Page 24: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

24 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar> <%--Helps to select multiple options from the given options--%> <asp:CheckBox ID="CheckBox1" runat="server" /> <%--Helps to select only one option from the given options--%> <asp:RadioButton ID="RadioButton1" runat="server" /> <%--Helps to select one or more options from the given list of options--%> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList> <%--Helps to browse and upload specified file to the server--%> <asp:FileUpload ID="FileUpload1" runat="server" /> <%--Helps to navigate from one page to the another page or website--%> <asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink> <%--Helps to place image on the website--%> <asp:Image ID="Image1" runat="server" /> <%--Acts as a container for other controls available in the Asp.Net--%> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> <%--Helps to place Advertisements on the webpage very easyly.--%> <asp:AdRotator ID="AdRotator1" runat="server" /> </div> </form> </body> </html>

Data Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Data Bound Controls--%> <%--Helps to display data in the form of graphical representation,like Bar Graphs, Line Graphs ,Column Graphs and Pie Chart etc.--%>

Page 25: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

25 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<asp:Chart ID="Chart1" runat="server"> <Series> <asp:Series Name="Series1"></asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1"></asp:ChartArea> </ChartAreas> </asp:Chart> <%--Helps to display data in the form of tabular format--%> <asp:DataList ID="DataList1" runat="server"></asp:DataList> <%--Helps to display data in the form of tabular format--%> <asp:GridView ID="GridView1" runat="server"></asp:GridView> <%--Helps to display data in the form of user defined format--%> <asp:Repeater ID="Repeater1" runat="server"></asp:Repeater> <%--Data Sourse Controls--%> <%--Helps to provide connection to the Sql Server database objects--%> <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource> <%--Helps to provide connection to the Xml objects--%> <asp:XmlDataSource ID="XmlDataSource1" runat="server"></asp:XmlDataSource> <%--Helps to provide connection to the LINQ objects--%> <asp:LinqDataSource ID="LinqDataSource1" runat="server"></asp:LinqDataSource> </div> </form> </body> </html>

Validation Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Helps to make sure value needs to submit for the control associate with RequiredFieldValidator control, probably TextBox control--%>

Page 26: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

26 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<div><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator></div> <%--Helps to make sure value needs to be specified in the given range like age b/w 18-30, for the control associate with RangeValidator control, probably TextBox control--%> <div><asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator"></asp:RangeValidator></div> <%--Helps to make sure value needs to be specified format like Email address, for the control associate with RegularExpressionValidator control, probably TextBox control--%> <div><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator></div> <%--Helps to make sure value needs to be same like Password and ConfirmPassword, for the control associate with CompareValidator control, probably TextBox control--%> <div><asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator"></asp:CompareValidator></div> <%--Helps to display all error messages at common place--%> <div><asp:ValidationSummary ID="ValidationSummary1" runat="server" /></div> <%--Helps to build own logic to validate user input if none of the avalilable Validation Controls not meet the requirement--%> <div><asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator></div> </div> </form> </body> </html>

Navigation Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Helps to provide Menu for applications --%>

Page 27: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

27 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<asp:Menu ID="Menu1" runat="server"></asp:Menu> <%-- Helps to provide SiteMap like Bread craumbs for the website--%> <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath> <%-- Helps to display information in a hierarchy level --%> <asp:TreeView ID="TreeView1" runat="server"></asp:TreeView> </div> </form> </body> </html>

Login Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Helps to build login form with membership providers very easily --%> <div><asp:Login ID="Login1" runat="server"></asp:Login></div> <%-- Helps to build ChangePassword form with membership providers very easily --%> <div><asp:ChangePassword ID="ChangePassword1" runat="server"></asp:ChangePassword></div> <%-- Helps to build Create new user form with membership providers very easily --%> <div><asp:CreateUserWizard ID="CreateUserWizard1" runat="server"> <WizardSteps> <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"> </asp:CreateUserWizardStep> <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"> </asp:CompleteWizardStep> </WizardSteps> </asp:CreateUserWizard></div> <%-- Helps to get Login Name with membership providers very easily --%> <div><asp:LoginName ID="LoginName1" runat="server" /></div> <%-- Helps to get Login Status with membership providers very easily --%> <div><asp:LoginStatus ID="LoginStatus1" runat="server" /></div> <%-- Helps to get Login View with membership providers very easily --%>

Page 28: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

28 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<div><asp:LoginView ID="LoginView1" runat="server"></asp:LoginView></div> <%-- Helps to get PasswordRecovery View with membership providers very easily --%> <div><asp:PasswordRecovery ID="PasswordRecovery1" runat="server"></asp:PasswordRecovery></div> </div> </form> </body> </html>

AJAX Extension Controls: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Helps to implement Asynchronous PostBack behaviour for the webform --%> <div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager></div> <%-- Helps to implement Asynchronous PostBack behaviour for the webform --%> <div><asp:UpdatePanel ID="UpdatePanel1" runat="server"></asp:UpdatePanel></div> </div> </form> </body> </html>

Which is the parent class of the Web server control?

The System.Web.UI.WebControls class is the parent class for all Web server controls.Namespace need

to use to work with server controls is using System.Web.UI.WebControls;

Explain the AdRotator Control?

The AdRotator is an ASP.NET control that is used to provide advertisements to Web pages. The

AdRotator control associates with one or many advertisements, which randomly displays one by one at

a time when the Web page is refreshed. The AdRotator control advertisements are associated with links;

therefore, when you click on an advertisement, it redirects you to other pages.

Page 29: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

29 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

The AdRotator control is associated with a data source, which is normally an xml file or a database table.

A data source contains all the information, such as advertisement graphics reference, link, and alternate

text. Therefore, when you use the AdRotator control, you should first create a data source and then

associate it with the AdRotator control.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- The AdRotator is an ASP.NET control that is used to provide advertisements to Web pages. --%> <asp:AdRotator ID="AdRotator1" Visible="false" runat="server" AdvertisementFile="~/AdRotatorFiles.xml" Target="_self" /> </div> </form> </body> </html>

AdRotatoe Xml file will be look like this

<?xml version="1.0" encoding="utf-8" ?> <Advertisements> <Ad> <ImageUrl>http://localhost:51924/Images/Dribbble.jpg</ImageUrl> <NavigateUrl>http://www.asp.net</NavigateUrl> <AlternateText>ASP.NET Logo</AlternateText> <Keyword>A</Keyword> <Impressions>33.33</Impressions> <Caption>This is the caption for Ad#1</Caption> </Ad> <Ad> <ImageUrl>http://localhost:51924/Images/images.jpg</ImageUrl> <NavigateUrl>http://www.sulekha.net</NavigateUrl> <AlternateText>www.Sulekha.net</AlternateText> <Keyword>S</Keyword> <Impressions>33.33</Impressions> <Caption>This is the caption for Ad#2</Caption> </Ad> <Ad>

Page 30: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

30 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<ImageUrl>http://localhost:51924/Images/Nature.png</ImageUrl> <NavigateUrl>AdRotator.aspx?ad=Widgets&amp;target=http://msdn.microsoft.com/widgets/</NavigateUrl> <AlternateText>www.neostream.net</AlternateText> <Keyword>S</Keyword> <Impressions>33.33</Impressions> <Caption>This is the caption for Ad#2</Caption> </Ad> </Advertisements>

Difference between GridView, Datalist and repeater?

Datalist:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Used to display information in the form of Table. It was introduced with Asp.Net 1.0. Built-in Paging and Sorting is not provided.We need to write our code Performance is fast is compared to GridView. --%> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> NewsInformationHeading: <asp:Label ID="NewsInformationHeadingLabel" runat="server" Text='<%# Eval("NewsInformationHeading") %>' /> <br /> NewsInformationDescription: <asp:Label ID="NewsInformationDescriptionLabel" runat="server" Text='<%# Eval("NewsInformationDescription") %>' /> <br /> <br /> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InIndiaV3.0ConnectionString %>" SelectCommand="SELECT [NewsInformationHeading], [NewsInformationDescription] FROM [tblNewsInformation]"></asp:SqlDataSource> </div> </form> </body> </html>

Page 31: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

31 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

GridView:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Used to display information in the form of Table. It was introduced with Asp.Net 2.0. Built-in Paging and Sorting are provided. Performance is slow compared to DataList. --%> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="true" AllowSorting="true"> <Columns> <asp:BoundField DataField="NewsInformationHeading" HeaderText="NewsInformationHeading" SortExpression="NewsInformationHeading" /> <asp:BoundField DataField="NewsInformationDescription" HeaderText="NewsInformationDescription" SortExpression="NewsInformationDescription" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InIndiaV3.0ConnectionString %>" SelectCommand="SELECT [NewsInformationHeading], [NewsInformationDescription] FROM [tblNewsInformation]"></asp:SqlDataSource> </div> </form> </body> </html>

Output:

NewsInformationHeading NewsInformationDescription

Sports Heading 3 Sports Description 3

Sports Heading 4 Sports Description 4

Sports Heading 5 Sports Description 5

Sports Heading 6 Sports Description 6

Business Heading 6 Business Description 6

Page 32: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

32 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Business Heading 1 Business Description 1

Business Heading 2 Business Description 2

Business Heading 3 Business Description 3

Business Heading 4 Business Description 4

Business Heading 5 Business Description 5

1 2 3 4 5

Repeater:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- By default repeater control doesn't have any structure.We need to provide structure for repeater controls It was introduced with Asp.Net 1.0. Built-in Paging and Sorting are not provided.We need to write code for that. Performance is fast compared to GridView. --%> <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <table> <td></td> <td> <asp:Label ID="NewsInformationHeadingLabel" runat="server" Text='<%# Eval("NewsInformationHeading") %>' /></td> <td> <asp:Label ID="NewsInformationDescriptionLabel" runat="server" Text='<%# Eval("NewsInformationDescription") %>' /></td> </table> </ItemTemplate> </asp:Repeater>

Page 33: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

33 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InIndiaV3.0ConnectionString %>" SelectCommand="SELECT [NewsInformationHeading], [NewsInformationDescription] FROM [tblNewsInformation]"></asp:SqlDataSource> </div> </form> </body> </html>

GridView: The HTML code generated has an HTML TABLE element created for the particular DataRow

and is a tabular representation with Columns and Rows. Datagrid has an in-built support for Sort, Filter

and paging the Data.

Datalist: An Array of Rows and based on the Template Selected and the RepeatColumn Property value

The number DataSource records that appear per HTML Repeater Control The Datarecords to be

displayed depend upon the Templates specified and the only HTML generated accordingly.

Repeater: Repeater does not have in-built support for Sort, Filter and paging the Data.

What are the HTML server controls in ASP.NET?

HTML server controls are similar to the standard HTML elements, which are normally used in HTML

pages. They expose properties and events that can be used programmatically. To make these controls

Programmatically accessible, you need to specify that the HTML controls act as a server control by

adding the runat="server" attribute.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <input id="Button1" runat="server" type="button" value="button" /> <input id="Text1" runat="server" type="text" /> </div> </form> </body> </html>

Where we can access these control information in code behind page.

using System;

Page 34: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

34 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //code to implement business logic Button1.Name = "Submit"; Text1.Value = "KnackHook"; } } }

What is difference between a Label control and a Literal control?

The Label control's final html code has an HTML tag; whereas, the Literal control's final html code

contains only text, which is not surrounded by any HTML tag.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Literal ID="Literal1" runat="server" Text="Literal1"></asp:Literal> </div> </form> </body> </html>

Final HTML Code:

<div> <span id="Label1">Label</span> Literal1 </div>

Page 35: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

35 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

What is the difference between a HyperLink control and a LinkButton control?

A HyperLink control does not have the Click and Command events; whereas, the LinkButton control has

these events, which can be handled in the codebehind file of the Web page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <div><asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink></div> <div><asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CommandName="LinkButton1_Click">LinkButton</asp:LinkButton></div> </div> </form> </body> </html>

Explain login controls?

Login controls are built-in controls in ASP.Net for providing a login solution to ASP.NET application. The

login controls use the membership system to authenticate a user credentials for a Web site.

There are many controls in login controls.

• ChangePassword control - Allows users to change their password.

• CreateUserWizard control - Provides an interface to the user to register for that Web site.

• Login control - Provides an interface for user authentication. It consists of a set of controls, such as

TextBox, Label, Button, CheckBox, HyperLink.

• LoginView control - Displays appropriate information to different users according to the user's status.

• LoginStatus control - Shows a login link to users, who are not authenticated and logout link, who are

authenticated

• LoginName control - Displays a user name, if the user logs in.

• PasswordRecovery control - Allows users to get back the password through an e-mail, if they forget.

In which database is the information, such as membership, role management, profile, and Web parts

personalization, stored?

The aspnetdb database stores all information.

Page 36: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

36 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

About basic difference between ASP and ASP.NET?

The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled.

This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. On

the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft

Intermediate Language (MSIL).

About ASP.NET Page Life cycle?

When we execute a ASP.NET Web page, it passes from the following stages, which are collectively

known as Web page lifecycle

PreInit: Is used to dynamically Create or recreate controls, set the master page or theme

dynamically.

Init: Is used for initialization of all controls in the page and also Useful to set some control

properties.

InitComplete: Use it when you need all the control initialization done

PreLoad: Some processing before Load event. After this the Page object loads the view-state

Load: Here we do common processing (e.g. GridView Binding)

LoadComplete

PreRender: Executed after data binding Make some final changes over controls

PreRenderComplete: Happens right before the page content is rendered

SaveStateComplete: Any changes over the page content are ignored

Unload: Page is unloaded from memory

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class PageLiftCycle : System.Web.UI.Page { //1.Check the IsPostBack property to determine whether this is the first time the page is being processed. //2.Create or re-create dynamic controls.

Page 37: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

37 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

//3.Set a master page dynamically. //4.Set the Theme property dynamically. protected void Page_PreInit(object sender, EventArgs e) { Response.Write("<br/>" + "PreInit"); //Dynamically add master page this.MasterPageFile = "KnackHook.master"; //Dynamically add Themes this.Theme = "ThemeName"; //Dynamically create controls TextBox tb = new TextBox(); tb.ID = "tbx1"; tb.Text = "KnackHook"; } //1.This event fires after each control has been initialized. //2.Each control's UniqueID is set and any skin settings have been applied. //3.Use this event to read or initialize control properties. //4.The "Init" event is fired first for the bottom-most control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself. protected void Page_Init(object sender, EventArgs e) { Response.Write("<br/>" + "Init"); } //1.Until now the viewstate values are not yet loaded, hence you can use this event to make changes to the view state that you want to ensure are persisted after the next postback. //2.Raised by the Page object. //3.Use this event for processing tasks that require all initialization to be complete. protected void Page_InitComplete(object sender, EventArgs e) { Response.Write("<br/>" + "InitComplete"); } //1.Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance. //2.Before the Page instance raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance. //3.Loads ViewState: ViewState data are loaded to controls. //4.Loads Postback data: Postback data are now handed to the page controls. protected override void OnPreLoad(EventArgs e) { Response.Write("<br/>" + "PreLoad"); } //1.The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.

Page 38: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

38 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

//2.This is the first place in the page lifecycle that all values are restored. //3.Most code checks the value of IsPostBack to avoid unnecessarily resetting state. //4.You may also call Validate and check the value of IsValid in this method. //5.You can also create dynamic controls in this method. //6.Use the OnLoad event method to set properties in controls and establish database connections. protected void Page_Load(object sender, EventArgs e) { //Binding data to grid view and other operations //partial code only don't threat it as complete code for databinding DataSet s=new DataSet(); GridView1.DataSource = s; GridView1.DataBind(); Response.Write("<br/>" + "Load"); } //1.Raised at the end of the event-handling stage. //2.Use this event for tasks that require that all other controls on the page be loaded. protected void Page_LoadComplete(object sender, EventArgs e) { Response.Write("<br/>" + "LoadComplete"); } //1.Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. //2.The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page. //3.The PreRender event of individual controls occurs after the PreRender event of the page. //4.Allows final changes to the page or its control. //5.This event takes place before saving ViewState, so any changes made here are saved. //6.For example: After this event, you cannot change any property of a button or change any viewstate value. //7.Each data bound control whose DataSourceID property is set calls its DataBind method. //8.Use the event to make final changes to the contents of the page or its controls. protected override void OnPreRender(EventArgs e) { Response.Write("<br/>" + "PreRender"); } //1.Raised after view state and control state have been saved for the page and for all controls. //2.Before this event occurs, ViewState has been saved for the page and for all controls. //3.Any changes to the page or controls at this point will be ignored. //4.Use this event perform tasks that require the view state to be saved, but that do not make any changes to controls. protected override void OnSaveStateComplete(EventArgs e) {

Page 39: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

39 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Response.Write("<br/>" + "SaveStateComplete"); } //1.This event is used for cleanup code. //2.At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object. //3.Cleanup can be performed on: // ◦Instances of classes, in other words objects //◦Closing opened files //◦Closing database connections. //4.This event occurs for each control and then for the page. //5.During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream. //6.If you attempt to call a method such as the Response.Write method then the page will throw an exception. protected void Page_UnLoad(object sender, EventArgs e) { //Runtime Error : Response is not available in this context. //Response.Write("<br/>" + "UnLoad"); //Error } }

In which event are the controls fully loaded?

Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init

events but you will see that view state is not fully loaded during this event.

How can we identify that the Page is Post Back?

Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //code to check pasge PostBack //For the first time when the page is loading IsPostBack is false,for futher submission it will be as true //if you want to execute the code for the first time then write the following condition if(IsPostBack==false) { //implement logic here }

Page 40: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

40 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

} } }

What is AutoPostBack?

If you want a control to postback automatically when an event is raised, you need to set the

AutoPostBack property of the control to True.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Here AutoPostBack="true" helps to post the form when some selections happend in the dropdown --%> <asp:DropDownList ID="drp1" runat="server" AutoPostBack="true"></asp:DropDownList> </div> </form> </body> </html>

About ASP.NET Validation Controls?

Validation controls are responsible to validate the data of an input control. Whenever you provide any

input to an application, it performs the validation and displays an error message to user, in case the

validation fails.

ASP.NET 4.0 contains the following six types of validation controls:

• CompareValidator - Performs a comparison between the values contained in two controls.

• CustomValidator - Writes your own method to perform extra validation.

• RangeValidator- Checks value according to the range of value.

• RegularExpressionValidator - Ensures that input is according to the specified pattern or not.

• RequiredFieldValidator - Checks either a control is empty or not.

• ValidationSummary - Displays a summary of all validation error in a central location.

Page 41: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

41 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Helps to make sure value needs to submit for the control associate with RequiredFieldValidator control, probably TextBox control--%> <%-- Name --%> <div><asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="tbxName" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <asp:TextBox ID="tbxName" runat="server"></asp:TextBox></div> <%--Helps to make sure value needs to be specified in the given range like age b/w 18-30, for the control associate with RangeValidator control, probably TextBox control--%> <%-- Age --%> <div><asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="tbxAge" MinimumValue="18" MaximumValue="30" Type="Integer" ErrorMessage="RangeValidator"></asp:RangeValidator> <asp:TextBox ID="tbxAge" runat="server"></asp:TextBox></div> <%--Helps to make sure value needs to be specified format like Email address, for the control associate with RegularExpressionValidator control, probably TextBox control--%> <%-- Email --%> <div><asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbxEmail" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator> <asp:TextBox ID="tbxEmail" runat="server"></asp:TextBox></div> <%-- Password --%> <div><asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="tbxPassword" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <asp:TextBox ID="tbxPassword" runat="server"></asp:TextBox></div> <%-- Confirm Password --%> <div><asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="tbxConfirmPassword" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <asp:TextBox ID="tbxConfirmPassword" runat="server"></asp:TextBox></div>

Page 42: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

42 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<%--Helps to make sure value needs to be same like Password and ConfirmPassword, for the control associate with CompareValidator control, probably TextBox control--%> <div><asp:CompareValidator ID="CompareValidator1" ControlToCompare="tbxPassword" ControlToValidate="tbxConfirmPassword" runat="server" ErrorMessage="CompareValidator"></asp:CompareValidator></div> <%--Helps to display all error messages at common place--%> <div><asp:ValidationSummary ID="ValidationSummary1" runat="server" /></div> <%--Helps to build own logic to validate user input if none of the avalilable Validation Controls not meet the requirement--%> <div><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" OnServerValidate="TextValidate" ControlToValidate="TextBox1" ErrorMessage="Text must be 8 or more characters."> </asp:CustomValidator></div> </div> </form> </body> </html>

For CustomValidator needs to write following method in code behind page.

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } //Event Handler to validate custom validation protected void TextValidate(object source, ServerValidateEventArgs args) { args.IsValid = (args.Value.Length >= 8); } }

Page 43: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

43 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

}

Differentiate between client-side and server-side validations in Web pages?

Client-side validations take place at the client end with the help of JavaScript and VBScript before the

Web page is sent to the server. On the other hand, server-side validations take place at the server end.

Which method is used to 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.

The Page.IsValid property helps to check whether page is valid or not.

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //Force the page to validate Page.Validate(); //Check to see whether page is validation successfully completed or not. //Page validation at server side if(Page.IsValid) { //Write logic here to handle business logic once page is validated. } } } }

What is the function of the CustomValidator control?

It provides the customize validation code to perform both client-side and server-side validation.

Which data type does the RangeValidator control support?

The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.

How do you prevent a validation control from validating data at the client end?

You can prohibit a validation control to validate data at the client side by setting the EnableClientScript

property to False.

Page 44: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

44 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Helps to make sure value needs to submit for the control associate with RequiredFieldValidator control, probably TextBox control--%> <%-- Name --%> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="tbxName" runat="server" ErrorMessage="RequiredFieldValidator" EnableClientScript="false"> </asp:RequiredFieldValidator> <asp:TextBox ID="tbxName" runat="server"></asp:TextBox> </div> </form> </body> </html>

Can we validate a DropDownList by RequiredFieldValidator?

Yes, we can validate a DropDownList by RequiredFieldValidator. To perform this validation, we have to

set the InitialValue property of RequiredFieldValidator control.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%--Helps to make sure value needs to submit for the control associate with RequiredFieldValidator control, probably TextBox control--%> <%-- Name --%> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="drpCountry" runat="server" ErrorMessage="RequiredFieldValidator" InitialValue="Select Country">

Page 45: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

45 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

</asp:RequiredFieldValidator> <asp:DropDownList ID="drpCountry" runat="server"></asp:DropDownList> </div> </form> </body> </html>

What is cross-page posting in ASP.NET?

The Server.Transfer() method is used to post data from one page to another. In this case, the URL

remains the same. However, in cross page posting, data is collected from different Web pages and is

displayed on a single page.

To do so, you need to set the PostBackUrl property of the control, which specifies the target page. In the

target page, you can access the PreviousPage property. For this, you need to use the

@PreviousPageType directive. You can access the controls of previous page by using the FindControl()

method.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="tbxName" Text="KnackHook" runat="server"></asp:TextBox> <asp:Button ID="btnClick" Text="Click" PostBackUrl="~/KnackHook1.aspx" runat="server" /> </div> </form> </body> </html>

In KnackHook1.aspx.cs

using System; using System.Collections.Generic; using System.Linq; using System.Web;

Page 46: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

46 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class KnackHook1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { TextBox SourcePageName = (TextBox)Page.PreviousPage.FindControl("tbxName"); lblName.Text = SourcePageName.Text; } } }

What are navigation controls? How many navigation controls are there in ASP.NET 4.0?

Navigation controls help you to navigate in a Web application easily. These controls store all the links in

a hierarchical or drop-down structure; thereby facilitating easy navigation in a Web application.

There are three navigation controls in ASP.Net 4.0. • SiteMapPath • Menu • TreeView

What do you mean by the Web Part controls in ASP.NET?

The Web Part controls are the integrated controls, which are used to create a Web site. These controls

allow the users to change the content, outlook, and state of Web pages in a Web browser.

List the features of the Chart control?

The following are the features of the Chart control:

• Bounds a chart with any data source.

• Simple manipulation of chart data, such as copying, merging, grouping, sorting, searching, and

filtering.

• Support many statistical and financial formulas for data analysis.

• Provide advanced chart outlook, such as 2-D, 3-D, lighting, and perspective.

• Support events and customizations.

• Includes interactivity with Microsoft AJAX.

• Supports AJAX Content Delivery Network (CDN).

What is event bubbling?

When child control send events to parent it is termed as event bubbling. - Server controls like Data grid,

Data List, and Repeater can have other child controls inside them.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html>

Page 47: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

47 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%-- Event bubbling is the command which parent control fires on behalf of the child. Event bubbling can be accomplished using row command event of grid view. --%> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="2" CellSpacing="2" HeaderStyle-BackColor="Brown" HeaderStyle-ForeColor="white" Width="500px" OnRowCommand="GridView1_RowCommand"> <Columns> <asp:TemplateField HeaderText="ID" SortExpression="ID"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "ID")%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Name" SortExpression="Name"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "Name")%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Section" SortExpression="section"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "section")%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Date Time" SortExpression="Time"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "Time")%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Button ID="btnAccept" CommandName="Accept" runat="server" Text="Accept" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Button ID="btnReject" CommandName="Reject" runat="server" Text="Reject" /> </ItemTemplate> </asp:TemplateField> </Columns> <HeaderStyle BackColor="Brown" ForeColor="White"></HeaderStyle> </asp:GridView>

Page 48: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

48 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

</div> </form> </body> </html>

using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GridView1.DataSource = PrepareData(); GridView1.DataBind(); } } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { //int index = Convert.ToInt32(e.CommandArgument); //GridViewRow row = GridView1.Rows[index]; if (e.CommandName == "Accept") { //Do something to accomplish accept command } else if (e.CommandName == "Reject") { //Do something to accomplish Reject command } else { //Do something to accomplish default command } } private DataTable PrepareData() { DataTable dt = new DataTable("testtable"); DataColumn dtid = new DataColumn("ID"); DataColumn dtname = new DataColumn("Name"); DataColumn dtsection = new DataColumn("section"); DataColumn dateandtime = new DataColumn("Time"); dt.Columns.Add(dtid);

Page 49: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

49 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

dt.Columns.Add(dtname); dt.Columns.Add(dtsection); dt.Columns.Add(dateandtime); dt.Rows.Add("1", "Madhan", "RTC", DateTime.Now.ToShortDateString()); dt.Rows.Add("2", "Kumar", "Police", DateTime.Now.ToShortDateString()); dt.Rows.Add("3", "Mamidala", "Army", DateTime.Now.ToShortDateString()); dt.Rows.Add("4", "Madhuvu", "Private", DateTime.Now.ToShortDateString()); dt.Rows.Add("5", "Vaddi", "Cinima", DateTime.Now.ToShortDateString()); return dt; } } }

Explain serialization and deserialization?

- Serialization is the process of converting an object into a stream of bytes. - Deserialization is the

process of creating an object from a stream of bytes.

Both these processes are usually used to transport objects.

using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { MyObject obj = new MyObject(); obj.n1 = 1; obj.n2 = 24; obj.str = "Some String"; //Serialization is the process of converting complex objects into stream of bytes for storage. //Example IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, obj); stream.Close(); //Deserialization is its reverse process, that is unpacking stream of bytes to their original form.

Page 50: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

50 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

//Example IFormatter formatter1 = new BinaryFormatter(); Stream stream1 = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj1 = (MyObject)formatter.Deserialize(stream1); stream.Close(); // Here's the proof of DeSerialization Response.Write(obj.n1); Response.Write( obj.n2); Response.Write(obj.str); } //The easiest way to make a class serializable is to mark it with the Serializable attribute as follows [Serializable] public class MyObject { public int n1 = 0; public int n2 = 0; public String str = null; } } }

About Page Directives?

Provide control over many options affecting the compilation and execution of the web form

Important directives:

@Page – main directive of the page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs"

Inherits="KnackHook.KnackHook" %>

Which is used to define Language and CodeBehind properties of a Page and its events.

@Import – imports a namespace into the form

<%@Import namespace="System.Drawing" %>

@Assembly – attaches an assembly to the form when it is compiled

<%@ Assembly Name ="myassembly" Src="~/KnackHook1.aspx.cs" %>

@OutputCache – controls the ability of the forms to use cache feature

<%@OutputCache Duration="15" VaryByParam="None" %>

@Register – registers a user control to be used in a web form

<%@Register Src="~/Login.ascx" TagName="Login" TagPrefix="Uc" %>

Page 51: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

51 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

@Master – defines a master for an application.

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.master.cs"

Inherits="WebApplication1.KnackHook" %>

How can you register a custom server control to a Web page?

You can register a custom server control to a Web page using the @Register directive.

About Master Pages?

Master pages in ASP.NET works as a template that you can reference this page in all other content

pages. Master pages enable you to define the look and feel of all the pages in your site in a single

location. If you have done changes in master page, then the changes will reflect in all the web pages that

reference master pages. When users request the content pages, they merge with the master page to

produce output that combines the layout of the master page with the content from the content page.

ContentPlaceHolder control is available only on master page. You can use more than one

ContentPlaceHolder control in master page. To create regions that content pages can fill in, you need to

define ContentPlaceHolder controls in master page as follows:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.master.cs" Inherits="WebApplication1.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html> The page-specific content is then put inside a Content control that points to the relevant

ContentPlaceHolder:

<%@ Page Title="" Language="C#" MasterPageFile="~/KnackHook.Master" AutoEventWireup="true" CodeBehind="KnackHook2.aspx.cs" Inherits="WebApplication1.KnackHook2" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> My Content Page Heading </asp:Content>

Page 52: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

52 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <h1>My Content Page Body</h1> </asp:Content>

Note that the ContentPlaceHolderID attribute of the Content control points to the ContentPlaceHolder

that is defined in the master page. The master page is identified by a special @ Master directive that

replaces the @ Page directive that is used for ordinary .aspx pages.

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.master.cs"

Inherits="WebApplication1.KnackHook" %>

About User Control?

User Control provides reusability behavior for asp.net webforms.It’s having extention as .ascx

Here we are developing Login form as User Control,this Login User Control will be used in any of the

applications or forsms by using register directive.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LoginUserControl.ascx.cs" Inherits="WebApplication1.LoginUserControl" %> <div> <table> <tr> <%-- Email --%> <td> <asp:Label ID="lblName" runat="server"></asp:Label></td> <td> <asp:TextBox ID="tbxEmail" runat="server"></asp:TextBox></td> <td> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbxEmail" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator></td> </tr> <%-- Password --%> <tr> <td> <asp:Label ID="lblPassword" runat="server"></asp:Label></td> <asp:TextBox ID="tbxPassword" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="tbxPassword" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> </tr> <tr> <td colspan="2"><asp:Button ID="btnLogin" Text="Login" runat="server" /></td> <td><asp:Button ID="btnReset" Text="Reset" runat="server" /></td> </tr>

Page 53: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

53 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

</table> </div>

Usage of Login User control.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <%@Register Src="~/LoginUserControl.ascx" TagName="Login" TagPrefix="Uc" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <Uc:Login id="Login" runat="server"></Uc:Login> </div> </form> </body> </html>

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.

How does a content page differ from a master page?

A content page does not have complete HTML source code; whereas a master page has complete HTML

source code inside its source file.

About ASP.NET State Managment?

State management is a technique to manage a state of an object on different request. The HTTP

protocol is the fundamental protocol of the World Wide Web. HTTP is a stateless protocol means every

request is from new user with respect to web server. HTTP protocol does not provide you with any

method of determining whether any two requests are made by the same person. Maintaining state is

important in any web application. There are two types of state management system in ASP.NET.

Page 54: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

54 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Client Side State Management: Cookies, Viewstate, Querystring and Hidden Fields

Advantages: Better scalability

Support for multiple browser

• - Cookies: Cookies are small piece of information that server creates on the browser. Cookies store a

value in the user’s browser that the browser sends with every page request to the web server.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KnackHook.aspx.cs" Inherits="KnackHook.KnackHook" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <%-- Email --%> <td> <asp:Label ID="lblName" runat="server"></asp:Label></td> <td> <asp:TextBox ID="tbxEmail" runat="server"></asp:TextBox></td> <td> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbxEmail" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator></td> </tr> <%-- Password --%> <tr> <td> <asp:Label ID="lblPassword" runat="server"></asp:Label></td> <asp:TextBox ID="tbxPassword" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="tbxPassword" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> </tr> <tr> <td colspan="2"> <asp:Button ID="btnLogin" Text="Login" runat="server" /></td> <td> <asp:Button ID="btnReset" Text="Reset" runat="server" /></td> </tr>

Page 55: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

55 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

</table> </div> </form> </body> </html>

Storing Cookies

using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //Storing Cookie Email and Password values inside cookies if (tbxEmail.Text != string.Empty && tbxPassword.Text != string.Empty) { //Cookies creation HttpCookie userInfo = new HttpCookie("UserCredentails"); userInfo["UserName"] = tbxEmail.Text; userInfo["Password"] = tbxPassword.Text; userInfo.Expires = DateTime.Now.AddMinutes(5);//This Cookie will be expire in 5 mins Response.Cookies.Add(userInfo); } } } }

Retrieving Cookies information

//Cookies HttpCookie reqCookies = Request.Cookies["UserCredentails"]; if (reqCookies != null) { UserName = reqCookies["UserName"].ToString(); Password = reqCookies["Password"].ToString(); }

Page 56: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

56 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

• - view state ASP.NET uses view state to track values in controls between page requests. It works within

the page only. You cannot use view state value in next page.

Stroring:

ViewState["UserName"] = tbxEmail.Text;

Retrieving:

string s = ViewState["UserName"].ToString();

• - control state: You can persist information about a control that is not part of the view state. If view

state is disabled for a control or the page, the control state will still work.

• - hidden fields: It stores data without displaying that control and data to the user’s browser. This data

is presented back to the server and is available when the form is processed. Hidden fields data is

available within the page only (page-scoped data).

• - Query strings: In query strings, values are stored at the end of the URL. These values are visible to the

user through his or her browser’s address bar. Query strings are not secure. You should not send secret

information through the query string.

//Sending Query String Response.Redirect("StateManagement.aspx?UserName=" + tbxEmail.Text +

",Password=" + tbxPassword.Text);

Retrieving:

//Query String string s = Request.QueryString["UserName"].ToString();

Server Side State Management:

Session State(w3wp.exe,asp.net state service), Application State(w3wp.exe) and Cache

Advantages: Better security

Reduced bandwidth

The following objects are used to store the information on the server:

Session State: Session object stores user-specific data between individual requests. This object is same

as application object but it stores the data about particular user.

Storing:

////Session Session["UserName"] = tbxEmail.Text;

Retrieving:

Page 57: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

57 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

string s = Session["UserName"].ToString();

Session Mode in Web.config file

<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="InIndiaV3.0ConnectionString" connectionString="Data Source=PTGHYDM\MAMIDALA;Initial Catalog=InIndiaV3.0;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <sessionState mode="InProc" timeout="20"></sessionState> <compilation debug="true" targetFramework="4.5"> <assemblies> <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </assemblies> </compilation> <httpRuntime targetFramework="4.5"/> </system.web> </configuration>

InProc: In this Mode, session data stroed inside IIS worker process which is w3wp.exe, when IIS

restarted automatically InProc mode session automatically lost.

StateServer: In this Mode, session data stroed inside ASP.NET State Service which is windows service.

Even when IIS restarted, StateServer mode session data still remains available for the usage.

<sessionState mode="StateServer" timeout="20"

stateConnectionString="tcpip=localhost:42424"></sessionState>

Sql Server: In this Mode, session data stroed inside Sql Server. Even when IIS restarted, Sql Server mode

session data still remains available for the usage.

<sessionState mode="SQLServer" timeout="20" sqlConnectionString="data source=.;integrated

security=SSPI;"></sessionState>

Application State: This object stores the data that is accessible to all pages in a given Web application.

The Application object contains global variables for your ASP.NET application.

Cache Object: Caching is the process of storing data that is used frequently by the user. Caching

increases your application’s performance, scalability, and availability. You can catch the data on the

server or client.

Page 58: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

58 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

What are the various session state management options provided by ASP.NET?

ASP.NET provides two session state management options – In-Process and Out-of-Process state

management.

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

- Out-of-Process stores data in an external data source. This data source may be a SQL Server or a State

Server service. Out-of-Process state management needs all objects stored in session to be serializable. .

What is Query String? What are its advantages and limitations?

The Query String helps in sending the page information to the server.

The Query String has the following advantages:

• Every browser works with Query Strings.

• It does not require server resources and so does not exert any kind of burden on the server.

The following are the limitations of Query String:

• Information must be within the limit because URL does not support many characters.

• Information is clearly visible to the user, which leads to security threats.

What is the lifespan for items stored in ViewState?

The items stored in ViewState live until the lifetime of the current page expires including the postbacks

to the same page.

What is the default timeout for a Cookie?

The default time duration for a Cookie is 30 minutes.

Which method has been introduced in ASP.NET 4.0 to redirect a page permanently?

The RedirectPermanent() method added in ASP.NET 4.0 to redirect a page permanently. The following

code snippet is an example of the RedirectPermanent() method:

RedirectPermanent("/path/Aboutus.aspx");

Which method is used to post a Web page to another Web page?

The Respose.Redirect method is used to post a page to another page, as shown in the following code

snippet: Response.Redirect("DestinationPageName.aspx");

How can you ensure that no one has tampered with ViewState in a Web page?

To ensure that no one has tampered with ViewState in a Web page, set the EnableViewStateMac

property to True.

Page 59: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

59 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

How many types of Cookies are available in ASP.NET?

ASP.NET manages the session state in the same process that processes the request and does not create

a cookie. It is known as a cookie less session. If cookies are not available, a session is tracked by adding a

session identifier to the URL. The cookie less session is enabled using the following code snippet:

<sessionState cookieless="true" />

What is the use of the <sessionState> tag in the web.config file?

The <sessionState> tag is used to configure the session state features. To change the default timeout,

which is 20 minutes, you have to add the following code snippet to the web.config file of an application:

<sessionState timeout="40"/>

Which method do you use to kill explicitly a users session?

The Session.Abandon() method kills the user session explicitly.

Explain the cookie less session and its working?

There are two types of Cookies available 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.

The user can set this period manually.

About ASP.NET Cache Management?

Type of Caching in ASP.NET

Output Caching

Data caching

Fragment caching

The @OutputCache directive’s Duration attribute determines how long the page is cached. If the

duration attribute is set to 60 seconds, the Web form is cached for 60 seconds; the server loads the

response in memory and retains that response for 60 seconds. Any requests during that time receive

the cached response. Once the cache duration has expired, the next request generates a new response

and cached for another 60 seconds.

What is the difference between page-level caching and fragment caching?

In the page-level caching, an entire Web page is cached; whereas, in the fragment caching, a part of the

Web page, such as a user control added to the Web page, is cached.

Page 60: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

60 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Explain the Application and Session objects in ASP.NET?

Application state is used to store data corresponding to all the variables of an ASP.NET Web application.

The data in an application state is stored once and read several times. Application state uses the

HttpApplicationState class to store and share the data throughout the application. You can access the

information stored in an application state by using the HttpApplication class property. Data stored in the

application state is accessible to all the pages of the application and is the same for all the users

accessing the application. The HttpApplicationState class provides a lock method, which you can use to

ensure that only one user is able to access and modify the data of an application at any instant of time.

Each client accessing a Web application maintains a distinct session with the Web server, and there is

also some specific information associated with each of these sessions. Session state is defined in the

<sessionState> element of the web.config file. It also stores the data specific to a user session in session

variables. Different session variables are created for each user session. In addition, session variables can

be accessed from any page of the application. When a user accesses a page, a session ID for the user is

created. The session ID is transferred between the server and the client over the HTTP protocol using

cookies.

About ADO.NET?

ADO.NET is an object-oriented set of libraries that allows you to interact with data sources. Commonly,

the data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file.

Data Providers:

ADO.NET provides a relatively common way to interact with data sources, but comes in different sets of

libraries for each way you can talk to a data source. These libraries are called Data Providers and are

usually named for the protocol or data source type they allow you to interact with.

Provider Name API prefix

Data Source Description

ODBC Data

Provider Odbc Data Sources with an ODBC interface. Normally older data bases.

OleDb Data

Provider OleDb Data Sources that expose an OleDb interface, i.e. Access or Excel.

Oracle Data

Provider Oracle For Oracle Databases.

SQL Data

Provider Sql For interacting with Microsoft SQL Server.

Page 61: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

61 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Borland Data

Provider Bdp

Generic access to many databases such as Interbase, SQL Server, IBM

DB2, and Oracle.

ADO.NET Objects:

ADO.NET includes many objects you can use to work with data.

The SqlConnection Object

To interact with a database, you must have a connection to it. The connection helps identify the database server, the database name, user name, password, and other parameters that are required for connecting to the data base. A connection object is used by command objects so they will know which database to execute the command on.

The SqlCommand Object

The process of interacting with a database means that you must specify the actions you want to occur. This is done with a command object. You use a command object to send SQL statements to the database. A command object uses a connection object to figure out which database to communicate with. You can use a command object alone, to execute a command directly, or assign a reference to a command object to an SqlDataAdapter, which holds a set of commands that work on a group of data as described below.

The SqlDataReader Object

Many data operations require that you only get a stream of data for reading. The data reader object allows you to obtain the results of a SELECT statement from a command object. For performance reasons, the data returned from a data reader is a fast forward-only stream of data. This means that you can only pull the data from the stream in a sequential manner This is good for speed, but if you need to manipulate data, then a DataSet is a better object to work with.

The DataSet Object

DataSet objects are in-memory representations of data. They contain multiple Datatable objects, which contain columns and rows, just like normal database tables. You can even define relations between tables to create parent-child relationships. The DataSet is specifically designed to help manage data in memory and to support disconnected operations on data, when such a scenario make sense. The DataSet is an object that is used by all of the Data Providers, which is why it does not have a Data Provider specific prefix.

Page 62: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

62 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

The SqlDataAdapter Object

Sometimes the data you work with is primarily read-only and you rarely need to make changes to the underlying data source Some situations also call for caching data in memory to minimize the number of database calls for data that does not change. The data adapter makes it easy for you to accomplish these things by helping to manage data in a disconnected mode. The data adapter fills a DataSet object when reading the data and writes in a single batch when persisting changes back to the database. A data adapter contains a reference to the connection object and opens and closes the connection automatically when reading from or writing to the database. Additionally, the data adapter contains command object references for SELECT, INSERT, UPDATE, and DELETE operations on the data. You will have a data adapter defined for each table in a DataSet and it will take care of all communication with the database for you. All you need to do is tell the data adapter when to load from or write to the database.

using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // 1. Instantiate the connection SqlConnection conn = new SqlConnection( "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI"); SqlDataReader rdr = null; try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand("select * from Customers", conn); // // 4. Use the connection //

Page 63: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

63 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

// get query results rdr = cmd.ExecuteReader(); // print the CustomerID of each record while (rdr.Read()) { Console.WriteLine(rdr[0]); } } finally { // close the reader if (rdr != null) { rdr.Close(); } // 5. Close the connection if (conn != null) { conn.Close(); } } } } }

Explain the difference between dataset and datareader?

-Datareader provides forward-only and read-only access to data

-Dataset object can hold more than one table from the same data sources as well as the relationships

between them.

-Dataset is a disconnected architecture

-Dataset can persist contents while datareader cannot persist contents.

Transactions in .Net?

A transaction symbolizes code or a set of components or procedures which must be executed as a unit.

All the methods must execute successfully or the complete unit fails. A transaction can be described to

cover the ACID properties for mission critical applications.

What are the ACID Properties?

1. Atomicity

2. Consistency

3. Isolation

4. Durability

Page 64: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

64 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Atomicity – All statements in a group must execute, or no statement in a group must execute.

Consistency – This follows naturally from atomic – a group of SQL statements must take the database from a known starting state to a known ending state. If the statements execute, the database must be at the known ending state. If the statements fail, the database must be at the known starting state.

Isolation – A group of statements must execute independently from any other statement groups being executed at the same time. If this wasn’t the case, it would be impossible for statement groups to be consistent – the known ending state could be altered by a code you have no control over or knowledge of. This is one of those concepts that are great in theory, but total isolation has important performance implications in the real world. More on how SQL Server implements this is explained later.

Durability – Once the group of SQL statements execute, the results need to be stored in a permanent media – if the database crashes right after a group of SQL statements execute, it should be possible to restore the database state to the point after the last transaction committed.

using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace KnackHook { public partial class KnackHook : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection db = new SqlConnection("connstringhere"); SqlTransaction transaction; db.Open(); transaction = db.BeginTransaction(); try { new SqlCommand("INSERT INTO TransactionDemo " + "(Text) VALUES ('Row1');", db, transaction) .ExecuteNonQuery(); new SqlCommand("INSERT INTO TransactionDemo " +

Page 65: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

65 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

"(Text) VALUES ('Row2');", db, transaction) .ExecuteNonQuery(); new SqlCommand("INSERT INTO CrashMeNow VALUES " + "('Die', 'Die', 'Die');", db, transaction) .ExecuteNonQuery(); transaction.Commit(); } catch (SqlException Ex) { transaction.Rollback(); } db.Close(); } }

}

About ASP.NET Globalization and Localization?

The globalization is a technique to identify the specific part of a Web application that is different for

different languages and make separate that portion from the core of the Web application. The

localization is a procedure of configuring a Web application to be supported for a specific language or

locale.

How information about the user's locale can be accessed?

The information regarding a user's locale can be accessed by using the System.Web.UI.Page.Culture

property.

Which namespaces are necessary to create a localized application?

The System.Globalization and System.Resources namespaces are essential to develop a localized

application.

About machine.config vs web.config?

Configuration files are used to control and manage the behavior of a web application.

The settings made in the Web.config file are applied to that particular web application only. Whereas

the settings of Machine.config file are applied to the whole asp.net applications.

Only one machine.config file can exist on a server.

Machine. config is configuration file for all the application in the IIS. But Web.config is a configuration

file for an application or folder.

ASP.NET configuration files are XML-based text files for application-level settings and are saved with the

name web.config. These files are present in

Page 66: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

66 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Multiple directories on an ASP.NET Web application server. The web.config file sets the configuration

settings to the directory it is placed in and to all the virtual sub folders under it. The settings in sub

directories can optionally override or change the settings specified in the base directory.

Following are the setting you can incorporate in web.config file.

Database connections

Error Page setting

Session States Error

Handling Security

Trace setting

Culture specific setting

What is the appSettings Section in the web.config file?

The web.config file sets the configuration for a Web project. The appSettings block in configuration 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=indiabixserver;

pwd=dbpassword; database=indiabix" /> </appSettings>

About ASP.NET Security?

Authentication & Authorization: Authentication verifies the identity of a user and authorization is a

process where you can check whether or not the identity has access rights to the system. In other

words, you can say that authentication is a procedure of getting some credentials from the users and

verify the user's identity against those credentials. Authorization is a procedure of granting access of

particular resources to an authenticated user. You should note that authentication always takes place

before authorization.

Authentication Types:

Windows Based Authentication

Form Based Authentication

Passport Authentication

What are the various ways of authentication techniques in ASP.NET?

There are various techniques in ASP.NET to authenticate a user. You can use one of the following ways

of authentication to select a built-in authentication provider:

• Windows Authentication - This mode works as the default authentication technique. It can work with

any form of Microsoft

Page 67: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

67 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Internet Information Services (IIS) authentication, such as Basic, Integrated Windows authentication

(NTLM/Kerberos), Digest, and certificates. The syntax of Windows authentication mode is given as

follows: <authentication mode="windows" />

• Forms Authentication - You can specify this mode as a default authentication mode by using the

following code snippet: <authentication mode="Forms"/>

• Passport - This mode works with Microsoft Passport authentication, as shown in the following code

snippet: <authentication mode = "Passport"/>.

Describe how Passport authentication works?

ASP.NET application with Passport authentication implemented checks the user’s machine for a current

passport authentication cookie. If it is not available, ASP.NET directs the user to a Passport sign-on page.

The Passport service authenticates the user, stores an authentication cookie on the user’s computer and

direct the user to the requested page.

Steps to be followed to use Passport authentication.

1. Install the Passport SDK.

2. Set the application’s authentication mode to Passport in Web.config.

3. Set authorization to deny unauthenticated users.

4. Use the PassportAuthentication_OnAuthenticate event to access the user’s Passport profile to

identify and authorize the user.

5. Implement a sign-out procedure to remove Passport cookies from the user’s machine.

Advantages of Passport authentication.

User doesn’t have to remember separate user names and passwords for various Web sites

User can maintain his or her profile information in a single location.

Passport authentication also avail access to various Microsoft services, such as Passport Express

Purchase.

How do you sign out from forms authentication?

The FormsAuthentication.Signout() method is used to sign out from the forms authentication.

What setting must be added in the configuration file to deny a particular user from accessing the

secured resources?

To deny a particular user form accessing the secured resources, the web.config file must contain the

following code:

<authorization >

Page 68: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

68 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

<deny users="username" />

</authorization>

What is Role-based security?

In the Role-based security, you can assign a role to every user and grant the privilege according to that

role. A role is a group of principal that restricts a user's privileges. Therefore, all the organization and

applications use role-based security model to determine whether a user has enough privileges to

perform a requested task.

About ASP.NET Tracing?

Tracing displays the details about how the code was executed. It refers to collecting information about

the application while it is running. Tracing information can help you to troubleshoot an application. It

enables you to record information in various log files about the errors that might occur at run time. You

can analyze these log files to find the cause of the errors.

In .NET, we have objects called Trace Listeners. A listener is an object that gets the trace output and

stores it to different places, such as a window, a file on your locale drive, or a SQL Server.

The System.Diagnostics namespace contains the predefined interfaces, classes, and structures that are

used for tracing. It supplies two classes, Trace and Debug, which allow you to write errors and logs

related to the application execution. Trace listeners are objects that collect the output of tracing

processes.

Why do you use the App_Code folder in ASP.NET?

The App_Code folder is automatically present in the project. It stores the files, such as classes, typed

data set, text files, and reports. If this folder is not available in the application, you can add this folder.

One of the important features of the App_Code folder is that only one dll is created for the complete

folder, irrespective of how many files it contains.

What is a multilingual Web site?

A multilingual Web site serves content in a number of languages. It contains multiple copies for its

content and other resources, such as date and time, in different languages.

What is IIS?

Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to ASP.NET

Web applications. It makes your computer to work as a Web server and provides the functionality to

develop and deploy Web applications on the server. IIS handles the request and response cycle on the

Web server. It also offers the services of SMTP and FrontPage server extensions. The SMTP is used to

send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form

handler.

Page 69: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

69 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Describe the Events in the Life Cycle of a Web Application?

A web application starts when a browser requests a page of the application first time. The request is

received by the IIS which then starts ASP.NET worker process (aspnet_wp.exe). The worker process then

allocates a process space to the assembly and loads it. An application_start event occurs followed by

Session_start. The request is then processed by the ASP.NET engine and sends back response in the

form of HTML. The user receives the response in the form of page.

The page can be submitted to the server for further processing. The page submitting triggers postback

event that causes the browser to send the page data, also called as view state to the server. When

server receives view state, it creates new instance of the web form. The data is then restored from the

view state to the control of the web form in Page_Init event.

The data in the control is then available in the Page_load event of the web form. The cached event is

then handled and finally the event that caused the postback is processed. The web form is then

destroyed. When the user stops using the application, Session_end event occurs and session ends. The

default session time is 20 minutes. The application ends when no user accessing the application and this

triggers Application_End event. Finally all the resources of the application are reclaimed by the Garbage

collector.

What are HTTP handlers in ASP.NET?

HTTP handlers, as the name suggests, are used to handle user requests for Web application resources.

They are the backbone of the request-response model of Web applications. There is a specific event

handler to handle the request for each user request type and send back the corresponding response

object.

Each user requests to the IIS Web server flows through the HTTP pipeline, which refers to a series of

components (HTTP modules and HTTP handlers) to process the request. HTTP modules act as filters to

process the request as it passes through the HTTP pipeline. The request, after passing through the HTTP

modules, is assigned to an HTTP handler that determines the response of the server to the user request.

The response then passes through the HTTP modules once again and is then sent back to the user.

You can define HTTP handlers in the <httpHandlers> element of a configuration file. The <add> element

tag is used to add new handlers and the <remove> element tag is used to remove existing handlers. To

create an HTTP handler, you need to define a class that implements the IHttpHandler interface.

What are the events that happen when a client requests an ASP.NET page from IIS server?

The following events happen when a client requests an ASP.NET page from the IIS server:

1. User requests for an application resource.

2. The integrated request-processing pipeline receives the first user request.

3. Response objects are created for each user request.

4. An object of the HttpApplication class is created and allocated to the Request object.

Page 70: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

70 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

5. The HttpApplication class processes the user request.

How can you send an email message from an ASP.NET Web page?

You can use the System.Net.Mail.MailMessage and the System.Net.Mail.SmtpMail classes to send an

email in your Web pages. In order to send an email through your mail server, you need to create an

object of the SmtpClient class and set the server name, port, and credentials.

What is the difference between the Response.Write() and Response.Output.Write() methods?

The Response.Write() method allows you to write the normal output; whereas, the

Response.Output.Write() method allows you to write the formatted output.

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

What are the navigation ways between pages available in ASP.NET?

Ways to navigate between pages are:

Hyperlink control

Response.Redirect method

Server.Transfer method

Server.Execute method

Window.Open script method.

What are Merge modules?

Merge modules are the deployment projects for the shared components. If the components are already

installed, the modules merge the changes rather than unnecessarily overwrite them. When the

components are no longer in use, they are removed safely from the server using Merge modules facility.

What is Satellite assembly?

Satellite assembly is a kind of assembly that includes localized resources for an application. Each satellite

assembly contains the resources for one culture.

Define secured sockets layer?

Secured Socket Layer (SSL) ensures a secured web application by encrypting the data sent over internet.

When an application is using SSL facility, the server generates an encryption key for the session and

page is encrypted before it sent. The client browse uses this encryption key to decrypt the requested

Web page.

Page 71: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

71 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

What is application domain?

It is the process space within which ASP.NET application runs. Every application has its own process

space which isolates it from other application. If one of the application domains throws error it does not

affect the other application domains.

Response.Redirect vs Server.Transfer?

Server.Transfer is only applicable for aspx files. It transfers page processing to another page without

making round-trip back to the client's browser. Since no round trips, it offers faster response and

doesn't update client url history list.

Response.Redirect is used to redirect to another page or site. This performs a trip back to the client

where the client’s browser is redirected to the new page.

Explain in what order a destructors is called?

Destructors are called in reverse order of constructors. Destructor of most derived class is called

followed by its parent's destructor and so on till the topmost class in the hierarchy.

Explain Global Assembly Cache?

Global Assembly Cache is the place holder for shared assembly. If an assembly is installed to the Global

Assembly Cache, the assembly can be accessed by multiple applications. In order to install an assembly

to the GAC, the assembly must have to be signed with strong name.

What is side-by-side execution?

This means multiple version of same assembly to run on the same computer. This feature enables to

deploy multiple versions of the component.

Define Resource Files?

Resource files contains non-executable data like strings, images etc that are used by an application and

deployed along with it. You can changes these data without recompiling the whole application.

What is CAS?

CAS is very important part of .Net security system which verifies if particular piece of code is allowed to

run. It also determines if piece of code have access rights to run particular resource. .NET security

system applies these features using code groups and permissions. Each assembly of an application is the

part of code group with associated permissions.

Difference between an EXE and a DLL?

An EXE is portable and executable with an entry point

A dll is not portable and executable since it has no entry point.

Page 72: ASP.NET Interview Questionsknackhook.com/InterviewQuestions/Asp.NetInterview... · 2019. 12. 28. · Dot Net Components: • Dot Net Framework • ASP.NET • Visual Studio About

72 | P a g e

KnackHook Knowledge Holder

[email protected] www.knackhook.com

Describe use of error pages in ASP.NET?

Error pages are used when exceptions are outside the scope of the application and the application can’t

respond directly to these exceptions. These types of exceptions are identified by HTTP response codes,

which IIS can respond to by displaying custom error pages listed in your application’s Web.config file.

Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process?

inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an

ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes

care of it by passing the request to the actual worker process aspnet_wp.exe.