Monday, August 29, 2011

Best Practice WCF For Beginners

WCF
Windows Communication Foundation

Windows Communication Foundation provides broad interoperability and direct Support for service orientation,
The Global Acceptance of web services, which includes standard protocols for application to application communication, has changed software development. For Example,The functions that web services now provide include security, distributed transaction coordination,and reliable communication. the benefits of the changes in web services should be reflected in the tools and technologies that developers use.

Windows Communication Foundation (WCF) is a Frame Work for Building Service-Oriented Applications.Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS,or it can be a service hosted in an application. An Endpoint can be a client of a service that request data from a service endpoint. the messages can be as simple as a single character or word sent as XML, or as complex as stream of binary data.

A service that Supplies Current Data to Others, such as a traffic report or other monitoring service.
A chat  service that allows two people to communicate or exchange data in real time.
A dashboard application that polls one or more services for data and presents it in a logical presentation.
Exposing a workflow implemented using windows workflow foundation as a wcf service.
A silverlight application to poll a service for the latest data feeds.

Service Orientation
Interoperatbility
Multiple Message Patterns
Service Metadata
Data Contracts
Security


Multiple Transports and Encodings
Reliable and Queued Messages
Durable Messages
Transaction
Ajax And REST Support
Extensibility

A simple Example of WCF Service



Tuesday, August 23, 2011

Application State Management in asp.net

Application State is a Data Repository available to all Classes in an ASP.Net application state is Stored in memory of the server and is faster than storing and retrieving information in a database. Unlike session state, which is  specific to single user session, application state applies to all users and sessions. Therefore, application state is useful place to store small amounts of ofter-used data that does not change from one user to another.

Application State is stored in an instance of the HttpApplicationState Class.

Saving values in Application State
(C#)
Application["UserName"]="SimpleUserName";
Application["values"]="Some values";

Reading the values
(C#)
string username= Application["UserName"].Tostring();



ASP.NET Page Life Cycle

ASP.NET Page Life-cycle

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 of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request a post back or a new request and sets Ispostback property. the page also sets the UICulture property.
Initialization :
During page initialization, controls on the pager are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. 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 postback, control properties are loaded with information recovered from view state and control state.
Post Back Event Handling
If the request is a postback, control event handlers are called. after that, the validate method of all validator controls is called, which sets the Isvalid property of individual validator controls an of the page
Rendering
Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing  a text writers its output to the output stream object of the page's response property.
Unload
The unload event raised 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 cleanup is performed.



How to Create Temparory Table

By using the below query we can able to create the temp table

SELECT * INTO #TEMPTABLENAME FROM TABLENAME