Define Error Events in Asp.Net?
In ASP.Net when any unhandled exception accurs in application then an event occures,that event called Error event.Two types of Event:
1. Page_Error:When exception occures in a page then this event raised.
2. Application_error:Application_Error event raised when unhandled exceptions in the ASP.NET application and is implemented in global.asax.
The error event have two method:
1. GetLastError: Returns the last exception that occurred on the server.
2. ClearError: This method clear error and thus stop the error to trigger subsequent error event.
How to create Multivalued Cookie ?
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
void btnSubmit_Click(Object s, EventArgs e)
Response.Cookies["preferences"]["firstName"] = txtFirstName.Text;
Response.Cookies["preferences"]["lastName"] = txtLastName.Text;
Response.Cookies["preferences"]["favoriteColor"] = txtFavoriteColor.Text;
Response.Cookies["preferences"].Expires = DateTime.MaxValue;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Set Cookie Values</title>
<form id="form1" runat="server">
<br /><br />
<br /><br />
<br /><br />
How do you require authentication using the Web.config file?
Include the following <authorization> element to require authentication:
<deny users="?" />
What is the difference between web.config and Machine.config files?
1. Usually on a webserver there is only one Machine.config file whereas in a web application there is no of files,but in the root directory.
2. Web.config file settings will override machine.config settings.
3. Machine.config file specifies configuration settings for all of the websites on the web server.Web.config file specify configuration settings for a particular web application, and is located in the applications root directory .Reply
What is the main difference between the Button server control and the Button HTML control?
Differences between Web and Windows applications?
Web Forms:Web forms use server controls, HTML controls, user controls, or custom controls created specially for Web forms.Web applications are displayed in a browser.Web forms are instantiated on the server, sent to the browser, and destroyed immediately.
Windows Forms:Windows forms are instantiated, exist for as long as needed, and are destroyed. Windows applications run on the same machine they are displayed on.Windows applications display their own windows and have more control over how those windows are displayed.
Describe the property of cookie in Asp.Net ?
1. Domain: The domain associated with the cookie for example, aspx.superexpert.com
2. Expires: The expiration date for a persistent cookie.
3. HasKeys: A Boolean value that indicates whether the cookie is a cookie dictionary.
4. Name: The name of the cookie.
5. Path: The path associated with the Cookie. The default value is /.
6. Secure: A value that indicates whether the cookie should be sent over an encrypted connection only. The default value is False.
7. Value: The value of the Cookie.
8. Values: A NameValueCollection that represents all the key and value pairs stored in a Cookie dictionary.
Write the code that creates a cookie containing the user name R4R and the current date to the user computer. Set the cookie to remain on the user computer for 30 days?
HttpCookie cookUserInfo = new HttpCookie("UserInfo");
CookUserInfo["Name"] = "R4R";
CookUserInfo["Time"] = DateTime.Now.ToString();
cookUserInfo.Expires = DateTime.Now.AddDays(30);
"HttpCookie" :The HttpCookie class is under System.Web namespace.
"CookUserInfo" :is the object of class HttpCookie
"Expires": is the property that sets the duration,when cookie expire.Reply
What do you mean by three-tier architecture?
The three-tier architecture was improve management of code and contents and to improve the performance of the web based applications. There are mainly three layers in three-tier architecture.This architecture remove the many drawbacks of previous Cliet-Server architecture.
There are three stages in this Architecture;
(2)Business Logic Layer:BL(Business Logic Layer) contain the server side code for data transaction, query and communicate through Data Base,and Pass the data to the user interface.
(3)Database layer:Data Layer represents the data store like MS Access, SQL Server, an XML file, an Excel file or even a text file containing data also some additional database are also added to that layers.
Define ASP.Net page life cycle in brief ?
1. OnInit (Init): Initializes each child control.
2. LoadControlState: Loaded the ControlState of the control. To use this method the control must call the Page.RegisterRequiresControlState method in the OnInit method of the control.
3. LoadViewState: Loaded the ViewState of the control.
4. LoadPostData: Controls that implement this interface use this method to retrieve the incoming form data and update the control According to there properties.
5. Load (OnLoad): Allows actions that are common to every request to be placed here. control is stable at this time, it has been initialized and its state has been reconstructed.
6. RaisePostDataChangedEvent: Is defined on the interface IPostBackData-Handler.
7. RaisePostbackEvent: Handling the clien side event caused Postback to occur
8. PreRender (OnPreRender): Allows last-minute changes to the control. This event takes place before saving ViewState so any changes made here are saved.
9. SaveControlState: Saves the current control state to ViewState.
10. SaveViewState: Saves the current data state of the control to ViewState.
11. Render: Generates the client-side HTML Dynamic Hypertext Markup Language (DHTML) and script that are necessary to properly display this control at the browser. In this stage any changes to the control are not persisted into
12. Dispose: Accepts cleanup code. Releases any unman-aged resources in this stage. Unmanaged resources are resources that are not handled by the .NET common language runtime such as file handles and database connections.