ASP.NET Interview Questions and Answers (1544) - Page 28

How you can make change in deployed ASP.NET web application without restarting the server or IIS?

Yes, after copying the new assembly files and the content files to the application folder, you can make change in deployed web application on the server without restarting the server or IIS. It automatically restarts the application when you replace the assembly. You needn't to install or register the assembly on the server.
What is ASP.NET Process recycling and how to configure it in machine.config file?

This technique helps you to configure the ASP.NET application, so that the application will automatically shut down and restart after a given period of time requested by the user or by the client. Also it has an ability to repair them through process recycling. You can also handle how the ASP.NET processes are recycled through attributes in the processModel element in the Machine.config file or else in web.config file.

To configure the process model you have to set some properties in machine.config file according to your requirement.

<configuration>

<system.web>
<processModel enable="true" timeout="60" requestLimit="Infinite" username="machine" password="AutoGenerate" />
</system.web>
</configuration>

List the different ProcessModel attributes which relates to process recycling in machine.config file?

Timeout attribute: It automatically recycles the process after a certain number of requests sent by the user or we can say the amount of time before the process is shut down and restarted.

Shutdown Timeout attribute: It determines each process will take how much time to shut down. After that time, the process is terminated by the system.

RequestLimit attribute: This attribute has the number of queued requests to serve before the process is shut down and restarted.

RestartQueueLimit attribute: This attribute specifies the number of queued requests to retain while the process is shut down and restarted.

MemoryLimit attribute: The percentage of physical memory the ASP.NET process is allowed to consume before that process is shut down and a new process is started. This helps to prevent memory leaks before it causes a breakdown in the server.

ResponseRestart - DeadlockInterval: It specifies the amount of time to wait before restarting a process because it was deadlocked. This helps to prevent applications with serious errors in the server.

ResponseDeadlockInterval: This is the time to wait before restarting a process that is a situation in which no progress can be made.
What are the three different types of Server Control Events?

The Server controls such as a Label, Button and Textbox each have their own sets of events that occur in response to the user requests. There are three types of server control events as mentioned below.

Postback events: This event occurs when a Web page is sent back to the server for further processing. These events effect on performance because they trigger a reverse back request to the server. A dropdown list can fire a post back if the AutoPostBack property of that dropdown list is set to true, else a cached event will fire.

Cached events: The Cache events are saved in view state of a processed page when a postback event occurs. If the AutoPostBack property is set to false then the server controls can trigger a cached event.

Validation events: These events can be enabled in configuration level or in page level. These types of events are handled on the page without any post back or caching. For security, this feature verifies that arguments to postback or callback events that originate from the server control.
What are different application level events?

Application_Start: It occurs when the user visits a page within your Web application.

Application_End: It occurs when there are no users of that application.

Application_BeginRequest: It occurs at the beginning of each request to the server. A request begins when a user navigates to some pages in the application.

Application_EndRequest: It occurs at the end of each request to the server.

Session_Start: It occurs when a new user visit a page within the application.

Session_End: It occurs when a user stops requesting to the pages in Web application and their sessions time out. It specifies the period mentioned in Web.config file.

Application_Error: It occurs when there is an unhandled exception in application.
In which levels, the events can occur in an ASP.NET web application?

In a Web application, the events can occur at the application level, page level, and server control level.
What is the difference between Application and Session Events?

By considering the application level you can have both Application and Session events. To initialize objects and to make data available to all the current sessions of your Web application we can use Application event. With the help of Session events you can initialize data that you want to share throughout all individual sessions but not in between the sessions.
Explain steps to optimize a web application for better performance?

Step-1: Turn off the debug option for a compiled application that is code compiled with release option runs faster than code compiled with debug option.

Step-2: Avoid postback of data between the client and server. Design the Web form in a way that it will complete the data on the Web form before user posts the data to the server. You can also use validation control to know the data complete on the client side before the page is submitted.

Step-3: Turn on or off the Session state according to the requirement i.e. you are designing your code to use some other techniques like cookies which is used to store client data etc.

Step-4: Make ViewState as off for server controls so that it needn't to retain their values. Saving ViewState information which leads to transmit data back to the server with each request.

Step-5: Use stored procedures with databases to execute more quickly.

Step-6: Use SqlDataReader rather than data set for data retrieval i.e. it is faster and consumes less memory than a data set.
What is Optimization?

The Optimization is a structured, systematic process for accessing codes and usually refers to writing code in such a way so that it executes more quickly and consumes fewer resources. It simply reflects to the good programming practices.
How long the instance of a web form is available on the web server?

When we will request a webpage from the browser, it will create an instance of that requested Webpage, which generates HTML to response to the request, and posts it on the browser. After post, it destroys the instance of that Webpage.

Let’s say at client side the browser has an HTML, in that the user can enter some text in textboxes, can select some required options, and perform other tasks until it fires any postback event, such as button click event. This causes the browser to send the submitted data back to the server for event processing. When the server receives client request, it will create a new instance of the Webpage and it fills supplied data, and processes requested event by the client. As server finishes task, it posts the resulting HTML back to the browser and destroys the instance of the Webpage.
Explain the ways to format output of an ASP.NET Web application?

There are two different ways to format the output of an ASP.NET web application.

Cascading style sheets (CSS): This is used to control the appearance of elements on a Web form. It also organizes all of the formatting information applied to HTML elements on a Web form which make easy to adjust the look and feel of Web applications. These styles can set the size, font, color and behavior of each specified HTML elements on the Web page.

Extensible Style sheet Language Transformations (XSLT): This is used to convert the mentioned data from an Extensible Markup Language (XML) file to HTML output and shows that information on the Web form. This XSLT puts data into HTML element from the XML file and applies styles on that element.
In which levels we can apply formatting to a web application?

• You can define styles in a style sheet file and that can be applied to all webforms referencing to the style sheet.

• You can also initialize styles in a page’s head element and that can be applied to all elements on the current page.

• You can also define styles inline in the HTML tag. These styles are applicable only to the HTML element in which these styles are defined.
Write the advantages of storing style definitions in a style sheet file (.css)?

• Easily you can maintain formatting i.e. when you will make change in style properties then it will reflect to the entire application.

• The sets of parallel formatting rules can be maintained in separate style sheets for formatting the output according to the user requirement. For example, an application may provide standard, enlarged-type, and printer-friendly style sheets which can be select by the user at run time.

• If you want to override the global styles then you should use page and inline styles. It depends on page and inline styles which is difficult to maintain the formatting in a Web application.
What is the use of Style Builder and how you can modify a style sheet using style builder?

This is used to change the appearance of any styles in a style sheet. The changes to the style sheet will change the appearance of Web form that references that style sheet.

To modify a style sheet using style builder, you need to follow these steps:

• First open the style sheet in Visual Studio which displays the style definitions in the Document window and also in the Tool window.

• Then select the style from Tool window to modify the definition of style property which will also display in the Document window.

• When you will right click on the style definition, a menu will appear. From that menu when you will select Build Style it displays the Style Builder Wizard.

• By using Style Builder you can compose the formatting which you want to add or modify in the selected style, and then click ok.

• After completion of above steps, you will get new or modified style attributes to the style definition.
Can you apply styles using class names and can you change it at run time?

Yes, you can apply style to different elements or different style to a single element in a class depending on the elements used. With the help of element IDs, you can also apply style to the element on a Web form.

Suppose you have created a style for a class, and then it automatically add a style definition to the style sheet using .classname identifier.

You can apply style to HTML elements by using the class attribute and to server control elements by using the CssClass attribute.

Yes, we can change the style sheet at runtime.
What is a validation group and how do you create a validation group?

This is a group which allows you to combine different validation controls in a single group on a page. With this, each validation group will going to perform its independent validation property as compared to other validation groups present on that page.

You can create a validation group by changing the ValidationGroup property to the same name for all the controls that you want to group. You can define a name to validation group, but you must have to use the same name for all controls of the group.
How a validation group works when the Page is posted?

When the page postbacks, then the IsValid property of Page class is set based on the validation controls present in the validationGroup. This group determines the caused validation occurred by the control. For example, if a button control with a validation group, let's say login group is clicked, then the IsValid property will return true if all validation controls whose ValidationGroup property is set to login group are valid.
Can a DropDownList fire validation controls?

Yes, a DropDownList control can fire validation control when the CausesValidation property of that validation control is set to true and the AutoPostBack property is set to true.
Why SetFocusOnError property is used for a validation control?

With the help of this property, you can specify the focus whether that is automatically set to the control specified by the ControlToValidate property or not or else by using the focus feature, the validators can be configured to set focus to their associated control to be validated when a validation error occurs. It will set when the validation control unable to validate. It allows us to update the appropriate control present in the control property. It will always move focus back to the field with the error after you tab out and an error occurs.
What is InitialValue property of a RequiredFieldValidator?

This property assigns the starting value for a input control. The default value is String.Empty. The validation control fails to validate, if the value of the associated input control is same as the InitialValue upon focus. With the help of this control you can make the input control as a mandatory field.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories