Saturday, March 20

WCF

Wcf is the windows communication foundation, which comes in dotnet 3.0 and 3.5,
you can communicate using http,tcp,msmq,It is service oriented architecture.

WCF is the Architecture, its divided into three types.

Using this you can communicate multiple platform, multifle servicies.

A-Address-when to communicate
B-Binding-how to communicate.
C-Contract-where to communicate

read ABC of WCF

Note:Webservice you can communicate only through http.

WCF comes up as a replacement for Remoting and Web service in dotnet.
The main feature of WCF is it's security. It can use the protocols like basice,wsHttp,tcp...wsHttp comes with default windows based security feature. WRT web services WCF works with the industry standard Contract based protocols. The componets WCF are data contract, Service Contract and the Service programme.

Wednesday, March 10

ASP.Net Page Life Cycle - Stage Description:

Page request:
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.

Start:
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.

Page initialization:
During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.

Load:
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.

Validation:
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.

Postback event handling:
If the request is a postback, any event handlers are called.

Rendering:
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.

Unload:
Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.

Cookies Vs Sessions

As far as my knowledge is concerned, cookies are stored on client side where as sessions are server variables. The storage limitations are also there (like IE restricts the size of cookie to be not more than 4096 bytes). We can store only a string value in a cookie where as objects can be stored in session variables. The client will have to accept the cookies in order to use cookies, there is no need of user's approval or confirmation to use Session variables cos they are stored on server. The other aspect of this issue is cookies can be stored as long as we want(even for life time) if the user accepts them, but with session variables we can only store something in it as long as the session is not timed out or the browser window is not closed which ever occurs first.

Coming to usage you can use both cookies and session in the same page.

We should go for cookies to store something that we want to know when the user returns to the web page in future (eg. remember me on this computer check box on login pages uses cookies to remember the user when he returns). Sessions should be used to remember something for that particular browser session (like the user name, to display on every page or where ever needed).

how to write and read cookies.

This eample code belongs to web site www.gotdotnet.com visit the following link for full example code and demo.

http://samples.gotdotnet.com/quickstart/aspplus/doc/stateoverview.aspx

Protected Sub Page_Load(sender As Object, e As EventArgs)
If Request.Cookies("preferences1") = Null Then
Dim cookie As New HttpCookie("preferences1")
cookie.Values.Add("ForeColor", "black")
...
Response.AppendCookie(cookie)
End If
End Sub

Protected Function GetStyle(key As String) As String
Dim cookie As HttpCookie = Request.Cookies("preferences1")
If cookie <> Null Then
Select Case key
Case "ForeColor"
Return(cookie.Values("ForeColor"))
Case ...
End Select
End If
Return("")
End Function

How to write and read session variables.

This example belongs to www.eggheadcafe.com visit the following link for quick summary and list of FAQs on Session State.

http://www.eggheadcafe.com/articles/20021016.asp

Basic use of Session in ASP.NET (C#):

STORE:
DataSet ds = GetDataSet(whatever parameters);
Session["mydataset")=ds;

RETRIEVE:
DataSet ds = (DataSet)Session["mydataset"];



web application is stateless protocol.
If we want some information to be travle from one page to another page in asp.net then we can use cookies as well as session.
cookies:-with the help of cookies we cal transfer the information from one page to another page but the value should be simple text,bt session can use any type of serialize data.
only 20 cookies for one host
session may be lot.
we can use multiple cookies.
cookies value can be change by user but session value is vary secure.

Thread Vs Process

Thread - is used to execute more than one program at a time.
process - executes single program

EXE Vs DLL

An EXE can run independently, whereas DLL will run within an EXE. DLL is an in-process file and EXE is an out-process file