11 October 2012

Common myths in Asp.net


Common myths in Asp.net :

C# code is faster than Visual Basic code:

·         if good programming practices are followed, there is no reason why Visual Basic and C# code cannot execute with nearly identical performance. To put it more succinctly, similar code produces similar results.

Codebehind is faster than inline :
·         It doesn't matter where your code for your ASP.NET application lives, whether in a codebehind file or inline with the ASP.NET page.

Components are faster than pages:
·         It is better to group functionality logically this way, but again it makes no difference with regard to performance.

For Each is better performance than For loop:
Really for loop has  better performance than Foreach statement





2 October 2012

Windows Communication Foundation - Overview


Windows Communication Foundation - Overview
Windows Communication Foundation (WCF) is a framework for building and running service-oriented applications. WCF unifies and extends the functionality of existing Microsoft connecting technologies, providing a single programming model independent of underlying communications protocols. WCF applications can interoperate with other technologies using open standards and protocols. 
Characteristics and Benefits
Windows Communication Foundation delivers the following primary benefits: service-oriented architecture (SOA) support, flexible support for messaging models, a unified programming model, protocol neutrality, increased reliability, standards-based interoperability, integrated security and messaging services, and a flexible architecture designed for extensibility.

Service-Oriented Architecture (SOA)

Windows Communication Foundation is based on the principles of service-oriented architecture and programming. Service-orientation is an important complement to object-orientation that applies the lessons learned from component software, message-oriented middleware, and distributed object computing. Whereas object-oriented development focuses on applications that are built from interdependent classes, service-oriented development focuses on systems that are built from a set of autonomous services. The internal implementation of each service could be object-oriented.
Client and server applications built with WCF are composed of .NET Framework 3.0-supplied and developer-created classes. For very complex applications, an intermediate level of organization, called component architecture may also be applied, as depicted for a service in the following diagram:
Bb756964.Top10_19(en-us,MSDN.10).gif
A set of deployed, interacting services is called a system. SOA interactions are loosely-coupled because all communication is based upon published contracts and policies, standardized protocols, and schematized information. Contracts describe published interfaces, their operations, and the corresponding messages.

Unified Programming Model

Windows Communication Foundation represents the next generation connecting technology that combines and extends the best attributes of existing connecting technologies to deliver a unified development and runtime experience. It provides a single API and a consistent, straightforward programming model that supersedes the following technologies:
  • DCOM and .NET Remoting support for efficient Remote Procedure Call (RPC) functionality.
  • ASP.NET Web Services (ASMX) support for easily configurable, interoperable Web Services.
  • .NET Framework Enterprise Services support for synchronization, distributed transactions, basic security, and distributed COM+ services.
  • Web Services Enhancements (WSE) support for open Web Service standards, collectively known as WS-* specifications. This includes security, reliable messaging, and distributed transactions specifications.
  • Queued messaging that is compatible with either MSMQ or the .NET Framework System.Messaging namespace technologies.

Flexible Support for Messaging Models

Classical Web services typically assume a request/reply message exchange pattern, where the client issues a request message and the service responds with a reply message. This pattern is particularly suited to HTTP because it is a stateless protocol with no delivery guarantees. In contrast, Windows Communication Foundation enables a wide variety of message topology solutions.
Two main communication state models are supported:
  • stateless model — messages are received with few or no guarantees. The stateless model is equivalent to most current-day Web services and is useful when broadcasting non-critical, one-way information.
  • stateful model — creates a communication session between two service objects. This model uses session state to enable Web services to provide advanced message functionality across the Internet, including callback methods, events, widely distributed transactions, and reliability and durability guarantees that enterprise applications require.
Three basic message-exchange patterns are supported:
  • Datagram — one-way invocation, no response.
  • Request/reply — one way invocation with response.
  • Duplex — two-way invocation.
    Request/reply and duplex messages can be invoked synchronously or asynchronously. Each node can act as a client, service, or both.
Windows Communication Foundation provides a variety of built-in transports and messaging protocols and supports custom transports and protocols. More complex messaging solutions (for example, publish-and-subscribe or peer-to-peer) can be built on top of these basic capabilities.

Protocol Neutrality and Flexibility

Windows Communication Foundation contains a set of predefined communication bindings (a binding is a set of communication characteristics including communication protocols) that will serve a wide range of common usage scenarios. However, the protocol-agnostic design of WCF supports flexibility in the following ways:
  • The messages exchanged between service and clients are defined in contracts that are independent of the protocols used to exchange those messages.
  • A single service can support multiple protocols simultaneously.
  • A pluggable communication infrastructure enables custom protocols to be defined and used in a straightforward manner.
Protocols can be selected through both imperative code and configuration files. Typically, the developer implements the logic of an application, including default protocols and minimum requirements, and the service administrator specifies configuration details at deployment, which often include the actual protocols used. These deployment-time policies do not require recoding or recompilation, enabling the administrator to tune the deployment of the service or client.

Reliability

The reliability and robustness of solutions built with the Windows Communication Foundation is assured for a number of reasons, including:
  • SOA requires loosely-coupled, autonomous clients and services, which increases unit isolation; the loss or corruption of one service does not bring down the entire solution.
  • Message delivery can be assured at either the transport level or at the message level using the WS-Reliable Messaging protocol. This guarantees that messages are delivered in a consistent pattern (for example, in-order and delivered exactly once).
  • For more sophisticated requirements, queued messaging through MSMQ is supported.
  • Powerful mechanisms are available to handle critical failures; internal application exceptions and external message faults are handled in an elegant and consistent fashion.
  • Distributed transaction support increases the reliability of a solution by enforcing operation consistency and further decreasing process coupling.
  • Perhaps most importantly, WCF eliminates the need for each organization or project to develop their own messaging infrastructure, freeing them to concentrate on developing code in their area of expertise.

Extensibility

Windows Communication Foundation supports extensibility through the following features:
  • A thoroughly extensible object model, making it possible to customize the product to suit specific customer needs.
  • Composable protocol channels that allow combining or stacking existing protocols to satisfy scenario requirements.
  • An architecture designed to support pluggable extension classes so that the following areas can be customized: protocols, transports, behaviors, bindings, serializers, message inspectors, and validators. These types of extensions are beyond the scope of this document, but for more information, see "Extending Windows Communication Foundation" in the Windows SDK.
From a developer's perspective, these extensibility features are both straightforward and powerful to use.

Integration and Interoperability

The Windows Communication Foundation assures a high level of compatibility with other Web services and existing Microsoft messaging technologies. Interoperability is often a primary concern for large scale, organization-wide solutions (for example, Enterprise Application Integration (EAI) and Business-to-Business Integration). Messaging interoperability issues fall into two categories:
  • With other messaging platforms, possibly residing on heterogeneous operating systems and programming languages
  • With other Microsoft services and messaging technologies
From a messaging perspective, WCF is designed to be platform-agnostic. Because it uses open WS-* standards to transport, format, and interpret messages, it can interoperate with any other messaging system that relies on these same standards. Specifically, WCF services will interoperate with any system that communicates using WS-I Basic Profile (BP)-compliant wire protocols. (The Web Services Interoperability Organization (WS-I) is a consortium of leading Web service leaders whose mission is to develop and promote interoperable messaging standards.) For example, WCF interoperates with existing ASP.NET Web services (ASMX). WS-* standards for reliability, security, and transactions are also supported, which makes it interoperable with the Web Services Enhancements for .NET Framework (WSE) 3.0.
The following diagram depicts the Web services stack and lists the primary standards supported at each level.
Bb756964.Top10_20(en-us,MSDN.10).gif
Microsoft has also done significant work to assure compatibility of Windows Communication Foundation with existing Microsoft technologies for building distributed systems (for example, Enterprise Services, COM+ services, and Message Queuing). Applications built with these existing technologies can now easily expose functionality as Web services. Windows Communication Foundation can communicate with these applications using standard Web service's profiles. The migration of existing applications that use .NET Remoting, ASP.NET Web services, and .NET Framework Enterprise Services to natively use the Windows Communication Foundation is often straightforward and cost-efficient. More information on specific integration approaches will be published on MSDN online.
From a general application development standpoint, Windows Communication Foundation integrates seamlessly with other managed technologies, and through .NET interop, with unmanaged technologies.

Integrated Security and Messaging Services

Security is a prime consideration. Message identity, confidentiality, integrity, authentication, authorization, and auditing are provided through transport- or message-level security mechanisms.
Security Level
Example
Description
Transport
HTTPS, SSL over TCP
Point-to-point security that protects the entire message by encrypting the communication stream. Transport-level security schemes are widely deployed and usually more efficient than message-level security.
Message
WS-Security family of specifications
End-to-end security where only message contents, or portions of them, are encrypted. Message-level security schemes are independent of transports and message-exchange patterns. Although they tend to be slower to process, they are much more flexible and extensible, and can use a variety of authentication schemes.
Windows Communication Foundation also provides a basic level of federation, in that a service can be configured to accept security credentials from multiple authorities, possibly using different identity and authorization schemes. Other areas of security (for example, authentication, non-repudiation, auditing, and resource protection) are provided by the .NET Framework or the Windows operating system.
In addition to basic delivery and security, a wide range of high-level message services are provided, including:
  • Metadata — WS-Policy, WS- Policy Attachments, and WS- Metadata Exchange protocols (in addition to WSDL used to describe Web services) are supported to dynamically convey service metadata.
  • Queued messaging — WCF delivers queued messaging functionality by using MSMQ as an underlying transport. Integration with an existing Message Queuing solution and the creation of a new asynchronous queue are both supported.
  • Transactions — WS-Atomic Transaction and WS-Coordination protocols are supported through the managedSystem.Transactions namespace. This service allows two or more nodes, possibly interoperating using WS-*protocols, to participate in a distributed transaction.
  • Content-based Routing — routing is enabled through support of the WS-Addressing protocol and custom WCF routers. Routing can be refined by filtering on content using the WCF filtering feature.

1 October 2012

Difference between WCF and Webservice in asp.net


Difference between WCF and Webservice in asp.net

-Webservices can be accessed only over HTTP and it works in stateless environment, WCF Service support  HTTP, TCP, IPC, and even Message Queues for communication.

- WCF is flexible because because its services can be hosted in different types of application like [IIS,WAS,Self-hosting and Managed Windows service]

- Webservices use XmlSerializer, But WCF uses DataContractSerializer, and it is good performance compare with XmlSerializer.

- DataContractSerializer can translate the HashTable into XML

- In webservice Only Public fields or Properties of .NET types can be translated into XML
- ASP.NET web services are compiled into a class library assembly and a service file with an extension   .asmx will have the code for the service.

-WCF Service can be hosted within IIS or WindowsActivationService.

-In ASP.NET Web services, unhandled exceptions are returned to the client as SOAP faults.
-In WCF Services, unhandled exceptions are not returned to clients as SOAP faults. To return SOAP faults    to clients, you can throw instances of the generic type, FaultException, using the data contract type as the    generic type.

-Web services provides only singlex communication,but WCF Supports shalf duplex and full duplex communication.

Half duplex

Half-duplex data transmission means that data can be transmitted in both directions on a signal carrier, but not at the same time.
half-duplex transmission implies a bidirectional line (one that can carry data in both directions).

They work in an stateless fashion over HTTP and are hosted inside a web server like IIS

Full duplex

Full-duplex data transmission means that data can be transmitted in both directions on a signal carrier at the same time.
Full-duplex transmission necessarily implies a bidirectional line (one that can move data in both directions).


WCF is a replacement for all earlier web service technologies from microsoft.

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...