Error is just an event, it occur when something wrong happened. When error event occurs, CLR creates an object of type Exception (located in System namespace. 

Note:Error is an event and exception is .Net object. 

Master pages provide functionality that developers have traditionally created by copying existing code, text, and control elements repeatedly; using framesets; using include files for common elements; using ASP.NET user controls; and so on. Advantages of master pages include the following:

  • They allow you to centralize the common functionality of your pages so that you can make updates in just one place.
  • They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.
  • They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.
  • They provide an object model that allows you to customize the master page from individual content pages.

Two options for tracking session IDs-

  • By default, ASP.NET uses cookie-based session tracking to keep track of user sessions. However, if a browser doesn?t support cookies, this does not work.
  • With cookieless session tracking, the session ID is encoded as part of the URL. As a result, cookieless session state works whether or not the browser supports cookies.

A method that creates a new cookie and adds it to the HttpResponse object

private void AddCookie()
{
HttpCookie nameCookie = new HttpCookie("UserName",txtUserName.Text)
nameCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(nameCookie);
}

A method that retrieves the value of a cookie from the HttpRequest object
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!(Request.Cookies["UserName"] == null))
lblUserName.Text = "Welcome back " + Request.Cookies["UserName"].value;
}
}

A method that deletes a persistent cookie

private void DeleteCookie()
{
HttpCookie nameCookie = new HttpCookie("UserName");
nameCookie.Expires = DateTime.Now.AddSeconds(-1);
Response.Cookies.Add(nameCookie);
}

There are two types of session events available in ASP.NET:

  • Session_Start
  • Session_End
You can handle both these events in the global.asax file of your web application. When a new session initiates, the session_start event is raised, and the Session_End event raised when a session is abandoned or expires.

We know that Http is stateless, means when we open a webpage and fill some information and then move to next page then the data which we have entered will lost.It happed do to Http protocol stateless nature. So here session come into existence, Session provide us the way of storing data in server memory. So you can store your page data into server memory and retrieve it back during page postbacks.

Stateless protocol is a communications protocol that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of requests and responses.

State management is the process by which you maintain state and page information over multiple requests for the same or different pages.

Advantages:

  • Session provide us the way of maintain user state/data.
  • It is very easy to implement.
  • One big advantage of session is that we can store any kind of object in it. eg, datatable, dataset etc
  • By using session we do not need to worry about data collapsed, because it store every client data separately.
  • Session is secure and transparent from the user.
Disadvantages:
  • Performance overhead in case of large volumes of data/user, because session data is stored in server memory.
  • Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.

PreviousDisplaying 5 of 7Next
1 2 3 4 5 6 7
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*