Friday, 24 November 2017

ASP.NET INTERVIEW QUESTIONS PART-2

1) What is ASP?
Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side technology, which helps in creating dynamic and user-friendly Web pages. It uses different scripting languages to create dynamic Web pages, which can be run on any type of browser. The Web pages are built by using either VBScript or JavaScript and these Web pages have access to the same services as Windows application, including ADO (ActiveX Data Objects) for database access, SMTP (Simple Mail Transfer Protocol) for e-mail, and the entire COM (Component Object Model) structure used in the Windows environment. ASP is implemented through a dynamic-link library (asp.dll) that is called by the IIS server when a Web page is requested from the server.

2) What is ASP.NET?
ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.

3) What is the 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).

4) 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.Page.Culture” property.

5) Which is the parent class of the Web server control?
The System.Web.UI.Control class is the parent class for all Web server controls.

6) Can you set which type of comparison you want to perform by the Compare Validator Control?
Yes, by setting the Operator property of the CompareValidator control.

7) What is the behaviour of a Web browser when it receives an invalid element?
The behaviour of a Web browser when it receives an invalid element depends on the browser that you use to browse your application. Most of the browsers ignore the invalid element; whereas, some of them display the invalid elements on the page.

8) What are the advantages of the code-behind feature?
The code-behind feature of ASP.NET offers a number of advantages:
1.      Makes code easy to understand and debug by separating application logic from HTML tags
2.      Provides the isolation of effort between graphic designers and software engineers.
3.      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.

9) How do you sign out from forms authentication?
The FormsAuthentication.Signout() method is used to sign out from the forms authentication.

10) 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.

11) Define 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.

12) What is the difference between a Default skin and a Named skin?
The default skin is applied to all the Web server controls in a Web form, which are of similar type, and it does not provide a Skin ID attribute. The named skin provides a Skin ID attribute and users have to set the Skin ID property to apply it.

13) What is actually returned from server to the browser when a browser requests an .aspx file and the file is displayed?
When a browser requests an .aspx file then the server returns a response, which is rendered into a HTML string.

14) How can you display all validation messages in one control?
The ValidationSummary control displays all validation messages in one control.

15) Which two new properties are added in ASP.NET 4.0 Page class?
The two new properties added in the Page class are MetaKeyword and MetaDescription.

16) What is tracing? Where is it used?
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 analyse 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.

17) 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.

18) Which ASP.NET objects encapsulate the state of the client and the browser?
The Session object encapsulates the state of the client and browser.

19) Differentiate 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.

20) 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");

21) 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.

22) What does the Orientation property do in a Menu control?
Orientation property of the Menu control sets the horizontal or vertical display of a menu on a Web page. By default, the orientation is vertical.

23) 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.

24) 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.

25) Suppose you want an ASP.NET function (client side) executed on the MouseOver event of a button. Where do you add an event handler?
The event handler is added to the Add() method of the Attributes property.

26) What is the default timeout for a Cookie?
The default time duration for a Cookie is 30 minutes.

27) 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.

28) Explain file-based dependency and key-based dependency.
In file-based dependency, you have to depend on a file that is saved in a disk. In key-based dependency, you have to depend on another cached item.

29) 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 website.
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 asTextBox, 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.

30) What is the use of Place Holder control? Can we see it at runtime?
The Place Holder control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. It used only as a container.

31) 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>
<deny users= “username”>
</authorization>

32) 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.

33) Make a list of all templates of the Repeater control.
The Repeater control contains the following templates:
·         ItemTemplate
·         AlternatingltemTemplate
·         SeparatorTemplate
·         HeaderTemplate
·         FooterTemplate

34) How can you assign page specific attributes in an ASP.NET application?
The @Page directive is responsible for this.

35) 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");

36) What are Custom User Controls in ASP.NET?
The custom user controls are the controls that are defined by developers. These controls are a mixture of custom behaviour and predefined behaviour. These controls work similar to other Web server controls.

37) What does the .WebPart file do?
The .WebPart file explains the settings of a Web Parts control that can be included to a specified zone on a Web page.

38) How can you enable impersonation in the web.config file?
To enable impersonation in the web.confing file, you need to include the <identity> element in the web.configfile and set the impersonate attribute to true as shown in the following code snippet:
<identity impersonate = "true" />

39) In which database is the information, such as membership, role management, profile, and Web parts personalization, stored?
The Asp.net database stores all information.

40) What do you understand by aggregate dependency?
Aggregate dependency allows multiple dependencies to be aggregated for content that depends on more than one resource. In such type of dependency, you need to depend on the sum of all the defined dependencies to remove a data item from the cache.

 41) How can you ensure that no one has tampered with ViewState in a Web page?
To ensure that no one has tampered with View State in a Web page, set the Enable View State Mac property to True.

42) What is the difference between adding items into cache through the Add() method and through the Insert() method?
Both methods work in a similar way except that the Cache.Add() function returns an object that represents the item you added in the cache. The Cache.Insert() function can replace an existing item in the cache, which is not possible using the Cache.Add() method.

43) Explain the cookie less session and its working.
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" />

44) Why do we need nested master pages in a Web site?
When we have several hierarchical levels in a Web site, then we use nested master pages in the Web site.

45) 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.

46) 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
through the project for database connection:
<configuration>
<appSettings>
<add key=”ConnectionString” value= “server” Pwd= “Db Password” database=”Name”/>
</appSetting>
</configuration>

47) To which class a Web form belongs to in the .NET Framework class hierarchy?
A Web form belongs to the System.Web.UI.Page class.

48) What does the "EnableViewState" property do? Why do we want it On or Off?
The EnableViewState property enables the ViewState property on the page. It is set to On to allow the page to save the users input between postback requests of a Web page; that is, between the Request and correspondingResponse objects. When this property is set to Off, the page does not store the users input during postback.

49) Which event determines that all the controls are completely loaded into memory?
The Page_Load event determines that all the controls on the page are fully loaded. You can also access the controls in the Page_Init event; however, the ViewState property does not load completely during this event.

50) 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.

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

52) 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.

53) Why a SiteMapPath control is referred to as breadcrumb or eyebrow navigation control?
The SiteMapPath control displays a hierarchical path to the root Web page of the Web site. Therefore, it is known as the breadcrumb or eyebrow navigation control.

54) Which namespaces are necessary to create a localized application?
The System.Globalization and System.Resources namespaces are essential to develop a localized application.

55) What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?
You can select more than one HtmlInputCheckBox Control from a group of HtmlInputCheckBox Controls; whereas, you can select only a single HtmlInputRadioButton
Control from a group of HtmlInputRadioButton Controls.

56) What is the difference between HTML and Web server controls?
HTML controls are client-side controls; therefore, all the validations for HTML controls are performed at the client side. On the other hand, Web server controls are server-side controls; therefore, all the validations for Web server controls are performed at the server side.

57) 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.
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.

58) What is the difference between absolute expiration and sliding-time expiration?
The absolute expiration expires, a cached item after the provided expiration time. The sliding time does not expire the cached items because it increments the specified time.

59) How can you check if all the validation controls on a Web page are valid and proper?
You can determine that all the validation controls on a Web page are properly working by writing code in the source file of the Web page using a scripting language, such as VBScript or JavaScript. To do this task, you have to loop across validator’s collection of pages and check the IsValid property of each validation control on the Web page to check whether or not the validation test is successful.

60) 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.

61) What are the Culture and UICulture values?
The Culture value determines the functions, such as Date and Currency, which are used to format data and numbers in a Web page. The UICulture value determines the resources, such as strings or images, which are loaded for a Web page in a Web application.

62) Which control will you use to ensure that the values in two different controls match?
You should use the CompareValidator control to ensure that the values in two different controls match.

63) What is the difference between a page theme and a global theme?
A page theme is stored inside a subfolder of the App_Themes folder of a project and applied to individual Web pages of that project. Global themes are stored inside the Themes folder on a Web server and apply to all the Web applications on the Web server.

64) 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"/>

65) Can you post and access view state in another application?
Yes, you can post and access a view state in other applications. However, while posting a view state in another application, the Previous Page property returns null.

66) Which method do you use to kill explicitly a user’s session?
The Session.Abandon() method kills the user session explicitly.

67) Which class is inherited when an ASP.NET server control is added to a Web form?
The System.Web.UI.WebControls class is inherited when an ASP.NET server control is added to a Web form.

68) What events are fired when a page loads?
The following events fire when a page loads:
Init() - Fires when the page is initializing.
LoadViewState() - Fires when the view state is loading.
LoadPostData() - Fires when the postback data is processing.
Load() - Fires when the page is loading.
PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
Unload() - Fires when the page is destroying the instances of server controls.

69) Write three common properties of all validation controls.
Three common properties of validation controls are as follows:
ControlToValidate - Provides a control to validate
ErrorMessage - Displays an error message
IsValid - Specifies if the control's validation has succeeded or not
Text - Displays a text for validation control before validation

70) 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

71) What happens if an ASP.NET server control with event-handling routines is missing from its definition?
The compilation of the application fails.

72) What are server-side comments?
Server-side comments are included in an ASP.NET page for the purpose of documentations
as shown in the following code snippet:
<%-- This is an example of server-side comments-- %>
The server-side comments begin with <%-- and end with -- %>.

73) How can we provide the WebParts control functionality to a server control?
We can provide the WebParts controls functionality to a server control by setting the Create Web Part property of WebPart Manger.

74) 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.

75) Which ASP.NET configuration options are supported in the ASP.NET implementation on the shared Web hosting platform?
There are many ASP.NET configuration choices, which are not able to configure at the site, application, or child directory level on the shared hosting environment. Some options can produce security, performance, and stability problem to the server and therefore cannot be changed.
The following settings are the only ones that can be changed in the web.config file(s) of your Web site:
browserCaps           clientTarget
pages                       customErrors
globalization           authorization
authentication         webControls
webServices

76) 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 Http Application State class to store and share the data throughout the application. You can access the information stored in an application state by using the Http Application 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 Http Application State 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.

77) How will you differentiate a submaster page from a top-level master page?
Similar to a content page, a submaster page also does not have complete HTML source code; whereas, a top-level master page has complete HTML source code inside its source file.

78) What are Web server controls in ASP.NET?
The ASP.NET Web server controls are objects on the ASP.NET pages that run when the Web page is requested. Many Web server controls, such as button and text box, are similar to the HTML controls. In addition to the HTML controls, there are many controls, which include complex behaviour, such as the controls used to connect to data sources and display data.

79) 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 code-behind file of the Web page.

80) What are the different ways to send data across pages in ASP.NET?
The following two ways are used to send data across pages in ASP.NET:
1.      Session
2.      Public properties

81) What does the WebpartListUserControlPath Property of a DeclarativeCatlogPart Control do?
The WebpartListUserControlPath property sets the route of the user defined control to aDeclarativeCatalogPart control.

82) 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.

83) What is the use of web.config? What is the difference between machine.config and web.config?
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 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.

The difference between the web.config and machine.config files is given as follows:
1.<WinDir>\Microsoft.NET\Framework\<version>\config\machine.config provides default configuration settings for the entire machine. ASP.NET configures IIS to prohibit the browser directly from accessing the web.config files to make sure that their values cannot be public. Attempts to access those files cause ASP.NET to return the 403: Access Forbidden error.
2.  ASP.NET uses these web.config configuration files at runtime to compute hierarchically a sole collection of settings for every URL target request. These settings compute only once and cached across further requests. ASP.NET automatically checks for changing file settings and do not validate the cache if any of the configuration changes made.

84) Can we validate a DropDownList by RequiredFieldValidator?
Yes, we can validate a DropDownList by RequiredFieldValidator. To perform this validation, we have to set theInitialValue property of RequiredFieldValidator control.

85) 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).

86) What is the use of Response.Redirect() method in ASP.NET?
This function (method) is used to redirect the user from one web page to another web page in asp.net.

87) What is the use of Response.Write() method in ASP.NET?
This function is used to show the message/Notification on the same web page.

88) Where the View State is stored in ASP.NET?
Client Side (page)

89) What is caching in ASP.NET?                                                                                 
Caching is used to store the data temporarily either on a web server or on the client side (client system).In other words, Caching is a place where data is stored temporarily. 

90) What are the advantages of caching in ASP.NET?
1)      Reduce the processing Time
2)      Reduce the Network Traffic
3)      Improve the Performance of web application
4)      Enhance the user Experience
5)      Lower Data used (Internet)
6)      Improve the site performance
7)      Large data management

91) What is difference between Client side Caching and Server side Caching? 
Client side Caching: - In client side scripting, data comes from the client Browser which is stored in client's hard disk. 
Server side Caching: - In server side caching, data comes from server cache memory. It is faster because data comes from cache.

92) What is difference between Label and Literal control in asp.net?
1)      Literal and Label control both are used to display the text (information) on the web form.
2)      On Browser side Label control is converted to HTML 'Span' tag but Literal control is not converting in any HTML tag.
      3)  We can provide formatting to the Label control but not to the Literal control.
      4)  If we want to show some HTML code and java script code then we used mainly
Literal control, not Label control. Encoding Mode is used with Literal control only.

93) What is Round Trip in asp.net?  
The trip of a Web page from the client to the server and then back to the client is known as a
round trip.
Round trip is path which page follows:-
Web page goes to Client side -request(forward)-->Server side --response(back) -->Client Browser (Client side),is known as round trip.

94) How to display Custom error in asp.net?                                                              
We can display Custom error instead of showing Browser side HTTP Error message to the client. We can specify Custom Error tag in web.config file.
Ex.
1<Custom Error Mode = "on" default Redirect=="CommanErrorapage.html"/>
<Error Status code = "403" redirect="NoAccess.html"/>
<Error Status code = "404" redirect="errorpage.html"/>


No comments: