Which is the parent class of the Web server control?
The System.Web.Ul.Control class is the parent class for all Web server controls.
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 PostBack?
Page object has an “IsPostBack” property, which can be checked to know that is the page posted back.
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.
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.
What is the difference between SQL notification and SQL invalidation?
The SQL cache notification generates notifications when the data of database changes, on which your cache item depends. The SQL cache invalidation makes a cached item invalid when the data stored in a SQL server database changes.
Can you set which type of comparison you want to perform by the CompareValidator control?
Yes, by setting the Operator property of the CompareValidator control.
How do you sign out from forms authentication?
The FormsAuthentication.Signout() method is used to sign out from the forms authentication.
What is AutoPostBack?
If you want a control to postback automatically when an event is raised, you need to set the auto-postback property of the control to True.
What is the function of the ViewState property?
The ASP.NET 4.0 introduced a new property called ViewStateMode for the Control class. Now you can enable the view state to an individual control even if the view state for an ASP.NET page is disabled.
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 dataset, 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.
Define a multilingual Web site.
A multilingual Web site serves content in a number of languages. It contains multiple copies of its content and other resources, such as date and time, in different languages.
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.
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.
What is IIS? Why is it used?
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.
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 actually returned from server to the browser when a browser requests a .aspx file and the file is displayed?
When a browser requests a .aspx file then the server returns a response, which is rendered into an HTML string.
How can you display all validation messages in one control?
The ValidationSummary control displays all validation messages in one control.
Which two new properties are added in ASP.NET 4.0 Page class?
The two new properties added in the Page class are meta keyword and meta description.
What is the difference between authentication and 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 to particular resources to an authenticated user. You should note that authentication always takes place before authorization.
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.
Which ASP.NET objects encapsulate the state of the client and the browser?
The Session object encapsulates the state of the client and browser.
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.
What is ViewState?
The ViewState is a feature used by ASP.NET Web page to store the value of a page and its controls just before posting the page. Once the page is posted, the first task by the page processing is to restore the ViewState to get the values of the controls.
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.
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”);
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, theResponse.Output.Write() method allows you to write the formatted output.
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.
Differentiate between client-side and server-side validations in Web pages.
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.
What is the default timeout for a Cookie?
The default time duration for a Cookie is 30 minutes.
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 element of a configuration file. The element tag is used to add new handlers and the element tag is used to remove existing handlers.
- To create an HTTP handler, you need to define a class that implements the IHttpHandler interface.
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.
How can you implement the postback property of an ASP.NET control?
You need to set the AutoPostBack property to True to implement the PostBack property of controls.
Explain how Cookies work. Give an example of Cookie abuse.
The server tells the browser to put some files in a cookie, and the client then sends all the cookies for the domain in each request. An example of cookie abuse is large cookies affecting the network traffic.
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 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.
What is the use of PlaceHolder control? Can we see it at runtime?
The PlaceHolder 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.
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:
What is the difference between page-level caching and fragment caching?
- In the page-level caching, an entire Web page is cached;
- In the fragment caching, a part of the Web page, such as a user control added to the Web page, is cached.
Describe the complete lifecycle of a Web page.
When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:
- Page request – During this stage, ASP.NET makes sure the page either parsed or compiled and a cached version of the page can be sent in response
- Start – During this stage sets the Request and Response page properties and the page check the page request is either a postback or a new request
- Page Initialization – During this stage, the page initialize and the control’s Unique Id property are set
- Load – During this stage, if the request is postback, the control properties are loaded without loading the view state and control state otherwise loads the view state
- Validation – During this stage, the controls are validated
- Postback event handling – During this stage, if the request is a postback, handles the event
- Rendering – During this stage, the page invokes the Render method to each control for return the output
- Unload – During this stage, when the page is completely rendered and sent to the client, the page is unloaded.
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”);
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 behavior and predefined behavior. These controls work similar to other Web server controls.
How can you enable impersonation in the web.config file?
To enable impersonation in the web.confing file, you need to include the element in theweb.config file and set the impersonate attribute to true as shown in the following code snippet:
How can you identify that the page is PostBack?
The Page object uses the IsPostBack property to check whether the page is posted back or not. If the page is postback, this property is set to true.
In which database is the information, such as membership, role management, profile, and Web parts personalization, stored?
The aspnetdb database stores all information.
What is State Management? How many ways are there to maintain a state in .NET?
State management is used to store information requests. The state management is used to trace the information or data that affect the state of the applications. There are two ways to maintain a state in .NET, Client-Based state management and Server-Based state management.
The following techniques can be used to implement the Client-Based state management:
- View State
- Hidden Fields
- Query Strings
- Control State
The following techniques can be used to implement Server-Based state management:
- Application State
- Session State
- Profile Properties
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.
What is the difference between adding items into cache through the Add() method and through theInsert() 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.
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.
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.
What are the major built-in objects in ASP.NET?
The major built-in objects in ASP.NET are as follows:
Where should the data validations be performed-at the client side or at the server side and why?
Data validations should be done primarily at the client side and the server-side validation should be avoided because it makes server task overloaded. If the client-side validation is not available, you can use server-side validation. When a user sends a request to the server, the validation controls are invoked to check the user input one by one.
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.
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.
What type of code, client-side or server-side, is found in a code-behind file of a Web page?
A code-behind file contains the server-side code, which means that the code contained in a code-behind file is executed at the server.
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.
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 corresponding Response objects. When this property is set to Off, the page does not store the users input during postback.
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.
What is the function of the CustomValidator control?
It provides the customize validation code to perform both client-side and server-side validation.
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.
Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.
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.
Where is the ViewState information stored?
The ViewState information is stored in the HTML hidden fields.
Which namespaces are necessary to create a localized application?
The System.Globalization and System.Resources namespaces are essential to develop a localized application.
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 HtmllnputRadioButton control from a group ofHtmlInputRadioButton controls.
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.
Explain the AdRotator Control.
The AdRotator is an ASP.NET control that is used to provide advertisements to Web pages. The AdRotatorcontrol 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.
What do you understand by the culture?
The culture denotes a combination of a language and optionally a region or a country. The contents of a Web page of a multilingual Web site are changed according to the culture defined in the operating system of the user accessing the Web page.
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.
What is the code-behind feature in ASP.NET?
The code-behind feature of ASP.NET enables you to divide an ASP.NET page into two files – one consisting of the presentation data, and the second, which is also called the code-behind file, consisting of all the business logic. The presentation data contains the interface elements, such as HTML controls and Web server controls, and the code-behind contains the event-handling process to handle the events that are fired by these controls. The file that contains the presentation data has the .aspx extension. The code behind file has either the .cs extension (if you are using the programming language C#) or the .vb (if you are using the programming language Visual Basic .NET) extension.
How can you check if all the validation controls on a Web page are valid and proper?
Explain the validation controls. How many validation controls in ASP.NET 4.0?
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.
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.
How many types of Cookies are available in ASP.NET?
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.
What is the use of the Global.asax file?
The Global.asax file executes application-level events and sets application-level variables.
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.
What is the difference between ASP session and ASP.NET session?
ASP does not support cookie-less sessions; whereas, ASP.NET does. In addition, the ASP.NET session can span across multiple servers.
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.
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.
What do you mean by a neutral culture?
When you specify a language but do not specify the associated country through a culture, the culture is called as a neutral culture.
What is the use of the tag in the web.config file?
The 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:
Which method do you use to kill explicitly a users session?
The Session.Abandon() method kills the user session explicitly.
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.
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.
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
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.
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 –%>.
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 CreateWebPart property of WebPartManger.
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 EnableClientScriptproperty to False.
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.
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.
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.
Deependra is a Senior Developer with Microsoft technologies, currently working with Opteamix India business private solution. In My Free time, I write blogs and make technical youtube videos. Having the good understanding of Service-oriented architect, Designing microservices using domain driven design.