Tuesday 4 March 2014

WCF basic tutorial

Introduction to Ends, Contract, Address and Bindings:

Ends.
      End point is associate among service and Application.
      End points have three important things.
        Contract
        Address
        Bindings

<endpoint address="http://localhost/Design_Time_Addresses/SampleService/Service1/"
                binding="basicHttpBinding“ contract="ServiceReference1.IEmpService"        
                name="BasicHttpBinding_IEmpService" />

Contract
             Contract is agreement between one or more service interfaces. You can describe parameters and return values for the service methods.
Address
            Addresses can indicate your service location i.e.URL
Bindings
           Bindings can determine how your end point going to be accessed. i.e. you have to access your service into SOAP over HTTP and binary over TCP. Your end point will create two bindings and support both bindings the service interface.

Specifications of WCF

       WCF supports all specifications.
       Which is called WS* Specifications.
       We have some list of specifications.
         Messaging (WS-Addressing)
         Security
         Reliability
         Transactions
         Metadata

Messaging (Ws-Addressing)
         Define some extra Additions SOAP headers.
         Optimize the transmission in MTOM (Message Transmission Optimization Mechanism).
         The Message Transmission Optimization Mechanism (MTOM) defines an optimized transmission format for SOAP messages based on the XML-binary Optimized Packaging (XOP) specification.


Security
         WS-Security
         WS-Trust
         WS-Secure Conversation
         The above security can define the authentication, data integrity and method privacy.

Reliability
         WS-Reliable
          This specification to ensure end to end communication to SOAP message back and forth at many times.


Transaction
         WS-Coordination
         WS-Atomic Transaction
         This specification can enable the transaction for your SOAP Messages.


Metadata  
         WS-Policy
         WS-Metadata Exchange
         WSDL implements done by metadata exchange protocols.
         WS-policy provides more feature to use this service.
         It’s support other language also C++, JAVA etc..

  

Type of Contracts in WCF

       Service Contract
       Operation Contract
       Data Contract

Service Contract
           This attribute define which application interface will be exposed as service.

Operation Contract
           The Operation Contract dictates which methods should be exposed to the external client using this service.

Data Contract
      The Data Contract attributes defines which type of complex data will be exchanged between the client and the service.  Determine which parameter to be serialized.


Thanks Guys 
                      Next post we will share about WCF bindings and  SOA (Service Oriented Architecture) 

Monday 27 January 2014

What's New in .NET Framework 4.5.1


Recently I am prepared to work Visual studio 2013, framework 4.5.1. But I need to know what features are implemented over there before i do work. So I am denoted some Microsoft web site and the speakers held some features or compared to lower versions.
Afterwards I confirmed myself to exact features and improvements of framework 4.5.1

Microsoft .NET Framework 4.5.1 is a couple of new features were introduced, as well as some improvements were implemented in the areas of Application Performance and Debugging applications.

Debugging Feature Improvements
  •     64-Bit Edit and Continue support in Visual Studio 2013
  •   Managed return value inspection
  •   ADO.NET Connection Resiliency
  •   Async Debugging Enhancements
  •   Improvements in Windows Store app development



Application Performance Improvements
  •  ASP.NET Application Suspension
  • On-Demand Large-Object heap compaction
  • Multi-core JIT Improvements

Friday 11 October 2013

The type of Client/Server Architecture in ASP.Net

Hi everyone,

             This article to describe the Client/Server  architecture of Asp.net. There are different types of        Client-Server architecture available. Some of them are 2-tier architecture, 3 tier architecture, 4 tier  architecture and n tier architecture.

Here to be explain that to simple.

2-tier Architecture

The 2tier architecture is the application logic is either buried inside the user interface on the client or within the database on the server. With two tier client/server architectures, the user system interface  is usually located in the user’s desktop environment and the database management service are usually in a server that is a more powerful machine that service many client. The process is split between the user system interface environment and the database management server environment.
                                             
          

3-tier Architecture

           The application logic or process lives in the middle tier ,it is separated from the data and the user interface. 3-tier systems are more scalable, robust and flexible. In addition, they can integrate data from multiple sources. In the 3 tier architecture, a middle tier was added between the user system interface client environment and the database management server environment. There are a variety of ways of implementing this middle tier can perform queuing, application execution and database staging. For example, if the middle tier provides queuing, the client can deliver its request to the middle layer and disengage because the middle tier will access the data and return the answer to the client. The three tier client/server architecture has been shown to improve performance for groups with a large number of users. The most basic type of three tier architecture has a middle layer consisting of Transaction Processing (TP) monitor technology. The TP monitor technology is a type of message queuing, transaction scheduling, and prioritization service where the client connects to the TP monitor (middle tier) instead of the database server.
                                         
                                                   



4-tier Architecture
            The 4-tier architecture is all of the data storage and retrieval processes are logically and usually physically located on a single tier. 4-tier architecture allows an unlimited number of programs to run simultaneously, send information to one another, use different protocols to communicate, and interact concurrently. This allows for a much more powerful application, providing many different services to many different clients. In this application we will have following 4-Tiers 
·         Business Object
·         Business Access Layer
·         Data Access Layer
·         UI -4 tier
               

Tuesday 8 October 2013

What is Bundling and Minification?


Guys, I wish to refer the next things going to be extremely interesting and it’s greatly useful, I am not going to explain briefly about this because I will refer the subsequently URL. It’s should be help for us. 

What is Bundling? (Little my knowledge share)
See! Bundling is a new feature for Visual studio 2012, especially given the feature to MVC 4 they had given separate file like Bundle.Config. Here we can initialized javascript  and Css files. Main advantage of use bundling reduce the Request load time, which mean see below table to explain the using bundling and minification.

Using B/M
Without B/M
Change
File Requests
9
34
256%
KB Sent
3.26
11.92
266%
KB Received
388.51
530
36%
Load Time
510 MS
780 MS
53%


Ok friends if you want to know more than about this please clicks here….

Thanks guys....

Saturday 28 September 2013

Vision Ingenious: Razor View Engine

Vision Ingenious: Razor View Engine: Recently me and my team has been working on has been a new view engine option for ASP.NET MVC4 WEB API, we should work new view engine Raz...

Razor View Engine

Recently me and my team has been working on has been a new view engine option for ASP.NET MVC4 WEB API, we should work new view engine Razor view. It’s new for every one including me. I see the samples; little impressed me I am trying to know about this.

WHAT?
Razor view was released for Microsoft Visual Studio 2010, Razor is a simple-syntax view engine and was released as part of ASP.NET MVC3 and the Microsoft WebMatrix tool set.
Razor is easy to learn and enables you to quickly be productive with a minimum of concepts. You use all your existing language and HTML skills. Razor doesn't require a specific tool and enables you to be productive in any plain old text editor –notepad to edit.
It’s not a new language, Supports "layouts" (an alternative to the "master page" concept in classic aspx pages).
The VS editor will also have the itellesense support that some of the other view engines don't have.
Declarative HTML Helpers also look pretty cool as doing HTML helpers within C# code reminds me of custom controls in ASP.NET. I think they took a page from partials but with the inline code.
HTML Encoding use @ block is automatically HTML encoded to better protect against XSS attack scenarios.
This is just Hello World Sample.
@{var message=”Hello World”;}
I Said : @message

i am try to compare Razor view and ASPX View engines, if may be missing any other point.

RAZOR View Engine
ASPX View Engine
The Razor View Engine is an advanced view engine that was introduced with MVC 3.0. This is not a new language but it is markup.
A web form view engine is the default view engine and available from the beginning of MVC
Razor has a syntax that is very compact and helps us to reduce typing.
The web form view engine has syntax that is the same as an ASP.Net forms application.
The Razor View Engine uses @ to render server-side content.
There is a different syntax ("<%: %>") to make text HTML encoded.
Razor does not require the code block to be closed, the Razor View Engine parses itself and it is able to decide at runtime which is a content element and which is a code element.
A web form View engine does not prevent Cross Site Scripting (XSS) attack.
The Razor Engine supports Test Driven Development (TDD).
Web Form view engine does not support Test Driven Development (TDD) because it depends on the System.Web.UI.Page class to make the testing complex.
There is only three transition characters with the Razor View Engine.
There are only three transition characters with the Razor View Engine.
The Razor View Engine is a bit slower than the ASPX View Engine.

Thanks Guys!! Hope you enjoy.....

Thursday 19 September 2013

Get MD5Hash from FileStream while partially reading

Hello friends,

Recently am worked to CryptoStream using MD5Hash related things and I need to calculate hash of a specified Stream while I was processing its data. I was trying to resolve various solutions and got some samples and customized that and resolve it. Here I will go to describe the difficulty and explanation.
Actually I need to get MD5Hash from filestream while partially reading. Before that we are doing to direct approach.
Along the way I discovered 3 additional methods to calculate hash – all suitable when you can’t rely on seeking in the stream.
Direct Approach for get Hash from container:
                      using (MD5 md5 = System.Security.Cryptography.MD5.Create())
            {
                md5.ComputeHash (inputStraeam);
                String containerHash = BitConverter.ToString(md5.Hash);
                return containerHash;
            }

This is the direct approach to calculate hash from data in stream, but its setback is that after calculating the hash value the stream is read to the end
 If the source stream was seekable (FileStream, MemoryStream…), you can just seek back and process the stream normally, but what if you can’t seek in the processing stream?

The block approach
The block approach you can calculate hash for filestream, using
You can calculate the hash on the go, using TransformBlock and TransformFinalBlock methods of MD5 class.
   using (MD5 md5 = MD5.Create())
        {
          byte[] data = new byte[4096];
          int numRead = 0;
          while ((numRead = inputStream.Read(data, 0, data.length)) > 0)
          {
                           
          md5.TransformBlock(data, 0, numRead, null, 0);

          }
           md5.TransformFinalBlock(data, 0, numRead);

         string fileHash = BitConverter.ToString(md5.Hash);
         fileHash = fileHash.Replace("-", "").ToUpper();
      }

This allows you to calculate the hash of the data at the same time to entire stream.



The block approach with Container position
The block approach with container position you to calculate the hash from set the fileStream position to read and end of stream.
using TransformBlock and TransformFinalBlock methods of MD5 class.
string fileHash = string.Empty;
long totalFileStreamFileStreamSize = fileStreamSize;
byte[] data = new byte[4096];
int readAmount = 0;

 if (fileStreamSize < data.Length)
 {
  readAmount = fileStreamSize;
 }
 else
 {
 readAmount = data.Length;
 }
 using (MD5 md5 = MD5.Create())
 {
 int numRead = 0;

 totalFileStreamFileStreamSize = totalFileStreamFileStreamSize + position;

 while ((numRead = container.Read(data, 0, readAmount)) > 0)
 {

 if ((totalFileStreamFileStreamSize - container.Position) <= readAmount)
 {
 readAmount = (int)(totalFileStreamFileStreamSize - container.Position);
 }
 // Compute MD5 hash
 if (container.Position != totalFileStreamFileStreamSize)
 {
 md5.TransformBlock(data, 0, numRead, null, 0);
 }
 else
 {
 md5.TransformFinalBlock(data, 0, numRead);
 }
 }
 fileHash = BitConverter.ToString(md5.Hash);
 fileHash = fileHash.Replace("-", "").ToUpper();
  }
The CryptoStream Approach
when we want to calculate hash value of output of your algorighm and do not have input in form of a stream, you can use CryptoStreamMode.Write.
using (MD5 md5 = new MD5CryptoServiceProvider())
{
using (CryptoStream writerOutputDocument = new CryptoStream(originalDocument, md5, CryptoStreamMode.Write))
{
while (totalRemaining > 0)
{
int numRead = inputContainer.Read(buffer, 0, readAmount);
if (numRead < 1)
{
throw new Exception("Unexpected end of file readingr.");
}
                                                                    writerOutputDocument.Write(buffer, 0, numRead);

totalRemaining -= numRead;
if (totalRemaining < buffer.Length)
{
 readAmount = (int)totalRemaining;
}
}
}
}

Note – when using CryptoStreamMode.Write, you need to indicate to the hash algorithm that all data is written.