Best Book for AIEEE


Stateless, which means a new instance of the web page class is re-created each time the page is posted to the server. As we all know HTTP is a stateless protocol, it can't hold the client information on page. If user inserts some information, and move to the next page, that data will be lost and user would not able to retrieve the information. So what we need? we need to store information. Session provides that facility to store information on server memory. It can support any type of object to store along with our custom object. For every client Session data store separately, means session data is stored as per client basis. Have a look at the following diagram. 
Advantages : Disadvantages : StateServer and SQLServer session mode we need to serialize the object before store. Current Application Domain. This is the best session mode which is based on web application Performance. But main disadvantage is that, It will lose the data if we restart the server. There are some more advantages and disadvantages of InProc session mode. I will come to those points again .memory object on that application domain. This is handled by worker process in application pool. So If we restart the server we will lose the session data. If Client request for the data , state provide read the data from In-Memory Object and return it to the client. In web.config we have to mention Session mode and also we have to set the Timeout. 
Session.TimeOut=30; There are two type of session events available in asp.net Session_Start() and Session_End. It is the only mode that supports the Session_End() event. These events will call after the session timeout period is over. The general flow for the 
Session_End() will call that depends on Session Time Out. This is a very fast mechanism because no serialization occurs for storing and retrieving data, and data are staying inside the same application domain. small web sites and where the number of user are very less, We should avoid InProc in case of Web Garden (I will come to this topic in details) Scenario . Advantages : serialization to store data in InProc Session Mode. web Garden scenarios . web farm scenarios also. Out-Proc Or StateServer Session Mode : Windows Services, which is Independent to IIS and can also run on a separate server. This session state is totally managed by aspnet_state.exe. This server may runs on the same system, but it's out side of that main application domain where your web application is running. This allow if you restart your asp.net process restarted your session data will be alive. This approaches has several disadvantages due to the overhead of serialization and de-serialization, its also increases the cost of data access because of every time when user retrieves session data, our application hits a different process.
secure and reliable Session management in asp.net. In this session mode, the Session data is serialized and stored in the SQL Server database. Main disadvantages of this session storage methods is overhead related with Data Serialization and De-Serialization. It is the best option for using in the web farms. Advantages :Disadvantages : SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587; // setup Smtp authentication
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("your_account@gmail.com", "yourpassword");
client.UseDefaultCredentials = false;
client.Credentials = credentials; MailMessage msg = new MailMessage();
msg.From = new MailAddress("your_account@gmail.com");
msg.To.Add(new MailAddress("destination_address@someserver.com"));
msg.Subject = "This is a test Email subject";
msg.IsBodyHtml = true;
msg.Body = string.Format("<html><head></head><body><b>Test HTML Email</b></body>");
try
{ client.Send(msg);lblMsg.Text = "Your message has been successfully sent.";
}catch (Exception ex)
{lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Error occured while sending your message." + ex.Message;
} <script type="text/javascript" language="javascript"> function GoBack() { window.history.forward(); } </script><body onload="GoBack();">
protected void Page_Load(object sender, EventArgs e){ Response.Cache.SetCacheability(HttpCacheability.NoCache);}