Force HTTPS Rule

      <rule name="Force HTTPS" enabled="true">
        <match url="(.*)" ignoreCase="true"/>
          <add input="{HTTPS}" pattern="off"/>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>


IIFE stands for: Immediately-Invoked Function Expression
It is a self-executing anonimous function like this:

    $.fn.myplugin = funnction(options) {
        var settings = {};
        $.extend(settings, this.myPlugin.defaults, options);
        return this;

    $.fn.myPlugin.defaults = {
        option1: 'option1',
        option2: 'option2',
        option3: 'option3'

Another good example

// Create an anonymous function expression that gets invoked immediately,
// and assign its *return value* to a variable. This approach "cuts out the
// middleman" of the named `makeWhatever` function reference.
// As explained in the above "important note," even though parens are not
// required around this function expression, they should still be used as a
// matter of convention to help clarify that the variable is being set to
// the function's *result* and not the function itself.

var counter = (function(){
  var i = 0;

  return {
    get: function(){
      return i;
    set: function( val ){
      i = val;
    increment: function() {
      return ++i;

// `counter` is an object with properties, which in this case happen to be
// methods.

counter.get(); // 0
counter.set( 3 );
counter.increment(); // 4
counter.increment(); // 5

counter.i; // undefined (`i` is not a property of the returned object)
i; // ReferenceError: i is not defined (it only exists inside the closure)


Passing Date parametere from Javascript to WCF

Having a service method that accepts two parameters will look like this:

public class ServiceRequest
Nullable<DateTime> DateTimeFrom {
get; set; }
Nullable<DateTime> DateTimeTo {
get; set; }

public interface IService
[WebInvoke(UriTemplate =
"getServiceCall", Method = "POST")]
ServResponse GetBusinessObjects(ServiceRequest filter);

Now, To start calling this method we need to construct a Json data representing the parameters.

      var fromDate = new Date(2013, 06, 18);
var toDate = new Date();

var datavar = {
DateTimeFrom: fromDate.toMSJSON(),
DateTimeTo: toDate.toMSJSON()
var parameters = JSON.stringify(datavar);

But, before calling the toMSJSON on date object we need to define it as follows:

// Let Date type be compatible for Microsoft WCF
Date.prototype.toMSJSON = function () {
/// <summary>Let Date type be compatible for Microsoft WCF.

var date = ‘/Date(‘ + this.getTime()  + ‘-0000)/’;


Getting DateTime from WCF

// convert WCF date to Javascript
String.prototype.DateWCF = function () {
/// <summary>convert string into Date</summary>
var matches = this.match(//Date(([0-9]+)(?:.*))//);
if (matches)
return new Date(parseInt(matches[1]));

Notice that when you use a date in javascript it is representing your local date based on the settings on your systemn and browser. As a result you might pass different notation to WCF. For example, my broweser has an timezone offset of -120 minutes. So when I ask to convert 06/20/2013 02:10:04 I see 2013-06-20T00:10:04.000Z which is perfectly normal because that represents the same exact time as I meant on my browser. Thus WCF will get the correct date aswell.

Minify js and css files in Visual Studio 2012

Finally we got an integrated tool in VS2012 that does the jobin Solution Explorer:
Web Essentials
You can enable this tool using the Extensions And Updates from the TOOLS menu.

  1. First, right-click on the css file and from the Web Essentials context menu choose to Minify CSS Files. This will ensure that with every build it will generate the accompanying .min.css file too.
  2. Make sure you have the Web.Release.config beside your web.config
  3. In your .aspx or .master file put an if statement to figure out if this is running on your debug mode or release mode:
<% if (HttpContext.Current.IsDebuggingEnabled) { %>
<link href="/css/MyFile.css" rel="stylesheet" type="text/css"></link>
<%} else {%>
<link href="/css/MyFile.min.css" rel="stylesheet" type="text/css"></link>
<%} %>

Do more with less

You can do more with less by reducing your design to its essence, and solving for distractions,
not discoverability. Create a clean and purposeful experience by leaving only the most relevant
elements on screen so people can be immersed in the content.

  • Be great at something instead of mediocre at many things.
  • Put content before chrome.
  • Be visually focused and direct, letting people get immersed in what they love, and they will explore the rest.
  • Inspire confidence in users. 

Desktop browsers have quite a lot of chrome (menus, options, status bars, and so on) that is
only sometimes useful. Typically, however, users open a browser to see a webpage, not to
interact with the browser. Moving commands off the browser chrome and into the app bar or
into charms helps users focus on what they care about.

Copied from Windows 8 User Experience Guidelines

Passed 70-480 exam

Yesterday morning I passed the exam in very short time (about an hour).
Amazingly, most of the questions were very familiar and the hints people provided earlier has been very helpful.

And a magor help from ExamCollection:

Finds Close Points by Distance

In this example I am trying to find the distance between the locations in a table and a given point. When I found the distance I will return thee result filtered by a allegible distance.

-- =============================================
-- Author: Asghar Panahy
-- Create date: 28-Feb-2013
-- Description: Zoekt objecten binnen bereik van gegeven punt
-- =============================================
ALTER PROCEDURE [dbo].[BereikbareObjecten]
-- Add the parameters for the stored procedure here
@orig_lat REAL ,
@orig_lng REAL,
@binnenMeter integer
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.


-- Select your SRID wisely. Don't follow me.
-- select * from sys.spatial_reference_systems
-- where spatial_reference_id in (4937, 4258, 4326, 4269)
DECLARE @SRID as int = 4326;

DECLARE @orig geography;
SET @orig = geography::Point(@orig_lat, @orig_lng, @SRID);

SELECT *,CONVERT(INT, @orig.STDistance( geography::Point([object].[Latitude], [object].[Longitude], @SRID))) As [Distance]
INTO #MyTempTable
FROM [Object]

SELECT * FROM #MyTempTable
WHERE [Distance] <= @binnenMeter
ORDER BY [Distance]