LATEST POSTS
Cross-Domain requests and CORS
A HTTP request is said to be a cross-domain request when a resource makes that request to a different domain than it originated from. Web pages frequently make Cross-Domain requests to load images, scripts and CSS files. Cross-Domain requests that are fired from JavaScript have some restrictions according to the Same-Origin Policy. Normally browsers don't allow making such requests due to security reasons.
Frequently we face scenarios to consume third-party services, feeds etc. from JavaScript, one of the ways to achieve that is through JSONP calls. But the JSONP mechanism has its own limitations they are used to make only HTTP GET requests and they are vulnerable to security issues. Because of the desires of web community the W3C has come up with a new policy called Cross-Origin Resource Sharing or simply CORS that makes cross-domain requests so easy and natural. In this article I'm going to discuss about the basic things of CORS.
Continue ReadingExploring the rare HTML elements
Hypertext Markup Language (HTML) is the predominant language for creating web pages. HTML consists of a rich set of elements for representing text, images and more. These elements act as the building blocks for creating web pages. Each HTML element is represented as a text enclosed in angle brackets ex. <img>. A HTML element can contain other HTML elements. There are restrictions for a HTML element to wrap other elements for ex. a <p> element should not contain other block elements like <div>.
In this article we are going to dig little deeper into the land of HTML and explore the rare elements that most of us are not much aware of.
Continue ReadingUsing HTTP Methods in REST
REST is the acronym of Representational State Transfer that represents a set of principles for creating distributed applications in web. It was first introduced and defined by Roy Fielding in the year 2000. Unlike the traditional RPC-style SOAP services that uses HTTP just as a transport layer, REST uses all the advantages of the HTTP like request verbs, URI, media-types, caching, security etc. Since REST services works like a normal website they are easy to create and consume compared to the RPC-style web services. Some of the famous REST services on the web are Amazon’s Simple Storage Service (S3), Sun Microsystem’s Cloud service, Atom Publishing Protocol etc.
In this article we will see about what are HTTP request methods and how we should use them for REST services.
Continue ReadingHow to display dates and times in clients timezone
Dates and times are very important in any online application. If you are making an online transaction it is important to record the date and time you are making the payment. Usually those values are recorded by the payment processing system and stored in a database. This payment processing system can be built using different server-side technologies like Java, ASP.NET, PHP etc. Most of these languages provides a built-in data-type to store date and time. The nice thing about web is the payment processing system and all the data associated with it is stored in a server that can be located in any part of the world and the users from all over the world can access the system for making payments through a browser.
Since different parts of the world have different timezones the same event can be represented by different date-times depending upon the timezone. In this article I’m going to explain you how we can display the date-time in clients timezone.
Continue ReadingReturning JSON from WCF Web API
WCF Web API is Microsoft's answer for creating RESTful services. Currently it is in preview state and you can download the binaries from here. For the people who are not aware of RESTful services, a RESTful service is a simple web service implemented using HTTP and that can be communicated using the normal GET, POST and other HTTP methods. Exposing a class as a RESTful service makes it easily accessible by wide variety of browsers and devices. In WCF Web API the REST service class is typically called as a resource and the format in which they exchange data is called as media type (ex. XML, JSON etc).
The WCF Web API uses the same routing module used in ASP.NET MVC to route the incoming requests to particular service class methods. In this small article I’m going to tell you how we can make the service to return data in JSON media-type.
Continue ReadingInteresting things from jQuery
jQuery is the most popular JavaScript library in use today. It is released by John Resig in January 2006 under the MIT and GNU General Public licenses. It is the library that is beloved by most of the web developers for scripting. It is very easy to learn, have a good documentation and a big community.
In this article I'm going to share you some of the interesting things from that library. If you do like jQuery and know some interesting things please post a comment.
Continue ReadingRouting Service and Content Based Routing
In Service Oriented Applications there are many cases we need an intermediate software between clients and services that bypasses the communication between them. The intermediate software is typically called as a router. Some of the well-known examples where we need a router are protocol mapping (ex. the service is exposed to tcp while the clients expects http), load-balancing (ex. distributing messages to services running in different servers in a round-robin fashion), content-based routing (routing messages to different services based upon the message content) etc.
WCF 4.0 ships with a new service called Routing Service that makes developers life so easy by separating out the routing logic from the clients and services. The nice thing about the Routing Service is it is so easily pluggable and configurable. This Routing Service is available under the new assembly System.ServiceModel.Routing.
In this article I’m going to describe about how we can achieve content-based routing using the WCF Routing Service.
Continue Reading