Configure Node.js for Windows

In this post we will walkthrough step by step to set up environment for node.js on windows. Very first navigate to Windows Azure Download page and select node.js for Windows to download

image

Once you click on node.js download option for Windows you will get following confirmation windows. Click on Save File.

image

After saving the file when you run the exe, it would launch a Web Platform Installer. You will get option to install Windows Azure SDK for Node.js. Click on Install button to proceed with installation

image

After successful installation you will get information about successful installed products as following in a dialog box.

image

After installation open command prompt as administrator and run the command

npm install azure-g

image

After successful installation of package create a working folder. For example I have created a folder called nodedemo in C drive. Now navigate to http://nodejs.org/ and copy the Hello Word sample from here

image

Create a file called server.js inside nodedemo folder and paste this code. After this run the command

node server.js

image

You will get message that node server is running. Now when you navigate to http:127.0.0.1:1337 , you should be getting following response from the server

image

Once you get this response you can be sure that node server is configured on windows. I hope you find this post useful. Thanks for reading.

 

Working with github on Windows

In this post we will see step by step to configure github for windows and the way to sync the project from windows to github repository. To start with very first you need to create a repository on github. To create repository login to github and click on New repository option

image

Once you click on New repository button you will get prompted to fill many information’s like repository name, description etc. You can make repository public or private by selecting respective radio button. If you are starting new then it is always good to initialize the repository with a README. It allows git to clone the repository immediately. Please refer below image for more on creating new repository

image

Once repository is created you will be navigated to repository page and can find all the information about repository as following image

image

At this point you have created repository in github and now you need to download and configure Windows Client of github on your machine. On the github page in the bottom you will find link to download windows client for github

 

image

After downloading and installing github windows client you will find icon on your desktop. Click that icon. Github windows client will be launched. In the left side you see local and github account. When you click on github account you will find all the repositories from the github.

 

image

To start working with github repositories, first you need to clone that. You will get clone button next to repository.

image

After successful cloning you will find button changed as shown in following image.

 

image

Double click on the repository to open it. After opening the repository you can notice in top a tool menu. From there you got option

  • Open in explorer
  • Open a shell here
  • View on github

image

To work with project select open in explorer. It will open the repository in windows explorer. Now suppose you have a visual studio solution you want to push on github, you need to follow below steps

Open VS project in window explorer and copy the solution.

image

You need to copy all files from VS solution open in windows explorer to github repository open in windows explorer.

image

After copying files to github repository open in windows explorer go to github for windows client and click on the refresh button

image

After refreshing double click on testproject repository. You may notice that a blue array next to repository name saying this repository has been modified. Click on the blue arrow or double click on the repository to navigate to detail repository page. On this screen you will find

  • Details of files to be committed
  • Option to commit the changes with comment

image

After providing comment you need to click on the commit button to commit the changes locally. After committing you will get message that one change committed locally though it is not synced.

image

To sync changes with github you need to click on sync button in top. If there is any locally committed change available then you will find sync button in blue else it would be in gray color. Once you click on sync button changes will get committed to github

image

You can verify sync in two ways. Either navigate to github and you will find all changes with comment there.

image

The other way is that you will see on github windows client in sync displayed.

image

The approach should be to put working files in local repository or cloned repository such that whenever you do any changes github for windows will detect that and you can locally commit and eventually sync with the github. In this way you can work with github and windows. I hope you find it useful. Thanks for reading.

 

Using O/R designer to bind a Windows Form in LINQ

In this post I will show you, how you could bind a Windows Form with Entity created by O/R designer. Essentially we are going to create a DataSource using generated entity of O/R designer.

I assume that,

1. You have created Windows Application project.

2. You have created Datacontext and entity class using LINQ to SQL class. Imagine you have dragged and dropped Person class on O/R designer from School database. Dbml file is looking more or less like below.

clip_image001

Follow the below steps to bind Windows Form,

1. Click on Data from top menu and choose Add New Data Source

clip_image002

2. Select Object as Data Source type

clip_image004

3. Choose Data object. Select Person from listed objects and click Finish

clip_image006

4. Navigate to Windows Form and open design surface and again click on Data in top menu and choose Show Data Sources

clip_image007

5. Now you will get Person in Data Sources listed. Select and drag on design surface.

clip_image009

In bottom of designer you can see Binding Data Source created

clip_image010

6. Now open the code Form class and add below code. Since you know to populate the data you need to set the Data Source of Binding Source as DataContext .

clip_image012

7. To save modification and add new rows , open Properties of Save button from navigation

clip_image013

Then in Properties Windows set Enabled as true.

clip_image014

8. In event of Save button write below code

clip_image016

Press F5 to run the application

clip_image017

Now you should able to perform all the operation.

I hope this post was useful. Thanks for reading Smile




Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Get Address from Contact in Windows Phone 7.1 [Mango]

In this post I will show you, how you could get Address from contact and Display it.

Expected Output

  1. On running of application you will get a button
  2. On click of button Contact list will be open
  3. On selection of a contact . address of that contact will be displayed in label.

imageimageimage

Design the page

I am going to put a very simple design. Design would have just one button and label.

On click event of the button, contact list would be open and on user selection of a contact, we will display address of that contact in label.  We are going to do very simple stuff . Don’t we ? Smile

Content Grid of MainPage.Xaml would be looking like below,

image

Write the Code

Add namespace

clip_image001

Globally defined a variable of type AddressChooserTask

 

clip_image002

 

In constructor of page create instance of AddressChooserTask and register completed event on that.

 

clip_image004

 

In the event, check whether TaskResult is equal to TaskResult enum OK. If yes then display name and address in label.

 

clip_image006

 

On click event of button, we will show the contact using addressChooserTask.Show

image

 

For you reference full source code of code behind is as below,

MainPage.Xaml.cs


using System;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;


namespace AddressChooser
{
    public partial class MainPage : PhoneApplicationPage
    {

        AddressChooserTask addressChooserTask;

        public MainPage()
        {
            InitializeComponent();
            addressChooserTask = new AddressChooserTask();
            addressChooserTask.Completed += new EventHandler<AddressResult>(addressChooserTask_Completed);

        }

        private void addressChooserButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                addressChooserTask.Show();
            }
            catch (System.InvalidOperationException ex)
            {

            }

        }

        void addressChooserTask_Completed(object sender, AddressResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                txtDisplay.Text = "The address for " + e.DisplayName + " is " + e.Address;
            }

        }
    }
}

Now when you run phone application you should get the expected output.

I hope this post was useful. Thanks for reading  Smile

NTLM and Windows Authentication on WCF service

Objective

This document will explain various combinations of IIS and WCF Ntlm/Windows authentication settings.

What is difference between NTLM and WINDOWS authentication in WCF?

Windows authentication = authentication in NTLM + authentication in Active Directory

NTLM authentication = authentication in only NTLM

IIS configuration

For all scenario IIS is configured for Windows authentication. What I mean is Windows Authentication is enabled and all other authentication is disabled. Navigate to below path to open ApplicationHost.Config file of IIS.

C:\Windows\System32\inetsrv\config\applicationHost.config

Binding used in WCF service

For all scenario basicHttpBinding being used for WCF service.

Scenario #1

Default setting for IIS Applicationhost.Config is

<windowsAuthentication enabled=false>

<providers>

<add value=Negotiate />
<add value=NTLM />
</providers>
</windowsAuthentication>

If IIS APP.Config file is having default setting, then we can have any authentication for WCF service corresponding IIS configured; WCF service will run as expected without any error.

Note: SharePoint is running as expected

Browsers Behavior with default settings

  1. IE 7.0 is not asking for authentication
  2. Fire Fox 3.5.6 is asking user to authenticate
  3. Safari 4.0.4 is asking user to authenticate

Scenario #2

If IIS Applicationhost.Config File setting has been modified as below, where forcefully Windows authentication is enabled for Kerberos then we have to modify service with Windows authentication.

<windowsAuthentication enabled=true><providers>
<add value=Negotiate />
<!–<add value=”NTLM” />–>
</providers>
</windowsAuthentication>

WCF configuration setting for Windows authentication should be

<basicHttpBinding>

<binding name=BasicHttpBinding>
<security mode =TransportCredentialOnly>
<transport lientCredentialType =Windows/>
</security>
</binding>
</basicHttpBinding>

 

Note: SharePoint is running as expected

Browsers Behavior with default settings

  1. IE 7.0 is not asking for authentication
  2. Fire Fox 3.5.6 is asking user to authenticate
  3. Safari 4.0.4 is asking user to authenticate

Scenario #3

If IIS Applicationhost.Config File setting has been modified as below, where forcefully Windows authentication is enabled for NTLM

<windowsAuthentication enabled=true>

<providers>

<!–<add value=”Negotiate” />–>

<add value=NTLM />
</providers>
</windowsAuthentication>

 And we go with Windows authentication for the service, we will get below error

<basicHttpBinding>

<binding name=BasicHttpBinding>

<security mode =TransportCredentialOnly>

<transport clientCredentialType =Windows/>

</security>

</binding>

</basicHttpBinding>

So to remove above error, WCF configuration setting for should be modified for the NTLM authentication.

<basicHttpBinding>

<binding name=BasicHttpBinding>

<security mode =TransportCredentialOnly>

<transport clientCredentialType =Ntlm/>

</security>

</binding>

</basicHttpBinding>

 

Note: SharePoint is running as expected

Browsers Behavior with default settings

  1. IE 7.0 is not asking for authentication
  2. Fire Fox 3.5.6 is asking user to authenticate
  3. Safari 4.0.4 is asking user to authenticate

Summary

Sl No

IIS (Applicationhost.Config ) setting

WCF (Web.config) setting

1 Default Ntlm and Windows Binding behavior
2 Windowauthentication = true and Value = Negotiate Windows authenticated Bidding behavior
3 Windowauthentication = true and Value = Ntlm Ntlm authenticated Binding behavior

So,

  1. If we have ApplicationHost.Config of IIS configured as default, we can have either of Ntlm or Windows authentications for WCF service.
  2. If we have ApplicationHost.Config of IIS configured as Ntlm, we can have only Ntlm authentication for WCF service.

If we have ApplicationHost.Config of IIS configured as Windows, we can have only Windows authentication for WCF service.