29 December 2013

HttpRequest.UrlReferrer in C# - To get clients previous request that linked to the current URL

HttpRequest.UrlReferrer in C#

Gets information about the URL of the client's previous request that linked to the current URL.

public Uri UrlReferrer { get; }

Uri MyUrl = Request.UrlReferrer;
Response.Write("Referrer URL Port: " + Server.HtmlEncode(MyUrl.Port.ToString()) + "< br >");
Response.Write("Referrer URL Protocol: " + Server.HtmlEncode(MyUrl.Scheme) + "< br >");




25 December 2013

Marshalling

Marshalling

Marshalling (sometimes spelled marshaling) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another.

Marshalling is similar to serialization and is used to communicate to remote objects with an object.


It simplifies complex communication, using custom/complex objects to communicate instead of primitives.
The opposite, or reverse, of marshalling is called unmarshalling.


XML VS JSON

XML VS JSON

XML - Extensible Markup Language
JSON - Javascript Object Notation

JSON
JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent.

JSON is more lighter and efficient than XML

JSON does not provide any display capabilities because it is not a document markup language.

XML

XML’s strength is extensibility and the avoidance of namespace clashes. It holds any data type and can be used to transport full documents with formatting information included. XML is best used when transporting something like a patient chart or text document with markup included.

XML provide display capabilities.

XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.

Finally,

JSON is a better data exchange format. XML is a better document exchange format. Use the right one for the right job.

SOAP VS REST

SOAP VS REST

SOAP - "Simple Object Access Protocol"

REST - "Representational state transfer"

REST
Standard and Unified methods like POST, GET, PUT and DELETE. Its work like how an  website makes a request using HTTP protocol.

Easy to use URI (Uniform resource identifier) format to locate any web resource.

REST is light weighted compared to SOAP

SOAP
SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. SOAP uses XML technologies to define an extensible messaging framework, which provides a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.

WCF SOAP
The WCF SOAP service can be categorized as operations-based, which means that a SOAP client calls a method that is available as a web service operation on a remote server, and receives a SOAP response.

WCF REST
A WCF REST service can be categorized as resource-based, which means that a REST client sends an HTTP request to programmatically accomplish a business objective. These requests largely employ a GET that is sent to a URI. In return, the client receives the corresponding resource.


1 December 2013

Difference Between Razor View Engine and ASPX View Engine in MVC

Difference Between Razor View Engine and ASPX View Engine in MVC

ASPX View Engine is the default view engine for the Asp.net MVC that is included with Asp.net MVC from the beginning.
Razor Engine is an advanced view engine that was introduced with MVC3. This is not a new language but it is a new markup syntax.

ASPX View Engine doesn't support TDD (Test Driven Development)
Razor Engine supports TDD (Test Driven Development)

ASPX View Engine support design mode in visual studio means you can see your page look and feel without running the application.
Razor Engine, doesn't support design mode in visual studio means you cann't see your design page look and feel.

ASPX View Engine is faster than Razor Engine.
Razor Engine is little bit slow as compared to Webform Engine.

Syntax
Webform uses <% and %>
for example
< %: Html.ActionLink("SignUp", "SignUp") % >
Razor uses @ symbol
for example
@Html.ActionLink("SignUp", "SignUp")


ASPX View Engine does not prevent XSS attacks means any script saved in the database will be fired while rendering the page.
Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.



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...