Sunday, May 31, 2015

Session : Getting Started Developing Universal Windows Platform (UWP) Apps at Microsoft Imagine Windows 10 Game Jam, Sri Lanka

Yesterday delivered a two hour session titled “Getting Started Developing Universal Windows Platform (UWP) Apps” at “Microsoft Imagine Windows 10 Game Jam, Sri Lanka”.

Started off with the session giving an introduction to what’s new for developers in Microsoft developer ecosystem. Then after explaining Universal Windows Platform, Universal Device Family, Child Device Families and how their versioning works, demoed the “Hello World” UWP app. After that talked about Extension SDKs and how we isolate device specific code using Windows.Foundation.Metadata.ApiInformation static class.

Winded up the session demoing two new XAML controls which was introduced with Windows 10 which are SplitView and RelativePanel.

Happy Coding.


Tuesday, May 26, 2015

Web API Resource Owner Password Flow : Returning Additional Properties along with Access Token

Web API uses the Resource Owner Password Flow defined in OAuth2. This is a quick post on how you can return additional properties when access token is requested by calling the token endpoint with a "grant_type" of "password".

When you created a ASP.NET Web API Project, insider the project, under “Providers” folder there will be a class named “ApplicationOAuthProvider”. As you know, the method which gets called when token endpoint is called, is “GrantResourceOwnerCredentials” and it returns a Task. So this is how you can include additional properties about the resource owner along with the access token. Simply add the values to AuthenticationProperties dictionary to store them as state values about the authenticated session.
ClaimsIdentity identity = new ClaimsIdentity(OAuthDefaults.AuthenticationType);
AuthenticationProperties properties = new AuthenticationProperties();
properties.Dictionary.Add("UserName", "jaliya.udagedara");
properties.Dictionary.Add("UserId", "1");
properties.Dictionary.Add("TwoFactorAuthenticationEnabled", "True");
AuthenticationTicket ticket = new AuthenticationTicket(identity, properties);

So this is how the result looks like.
Hope this helps.

Happy Coding.


Monday, May 18, 2015

Visual C# Technical Guru - April 2015

Another month as a judge in Microsoft TechNet Guru Awards under Visual C# category.

The TechNet Guru Awards celebrate the technical articles on Microsoft TechNet.

Post in WikiNinjas Official Blog,
Visual C# Technical Guru - April 2015
Happy Coding.


Sunday, May 10, 2015

Debugging Universal Windows Platform (UWP) Apps Without Having Windows 10 Installed in Your Physical Machine

If you are not running on Windows 10 Preview in your physical machine and if you have started developing Universal Windows Platform (UWP) Apps with Visual Studio 2015 RC, you must be feeling worried that you can only debug your applications on phone emulators running Windows 10.
Well you don’t have to worry anymore, there is one thing that you can do. That is debug on a remote device. For that,
  • The remote device and the Visual Studio computer must be connected over a network or connected directly through an Ethernet cable. Debugging over the internet is not supported.
  • The remote device must be running the remote debugging components.
  • You must be an administrator to install the remote tools on the remote device. To communicate with the remote tools, you must have user access to the remote device.
The simple way to achieve this, is by setting up a virtual machine running Windows 10 Insider Preview Build 10074 and install Remote Tools for Visual Studio 2015 RC which can be downloaded from here.

The steps to try it out is fairly simple.

Once Remote Tools for Visual Studio 2015 RC is installed Visual Studio 2015 RC Remote Debugger can be found on “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\{version}\msvsmon.exe”. Now start the Visual Studio 2015 RC Remote Debugger on the virtual machine.

Visual Studio 2015 RC Remote Debugger
Now make sure you can ping from host to guest.

Then from Visual Studio change your debug target to Remote Machine and you will be prompted to enter some information for the remote connection.

Visual Studio Change Debug Taret
Remote Connection Information
Enter the IP Address of the virtual machine, click on Select and then start debugging. In the Output Window of Visual Studio you can see the status of the deployment and on the virtual machines’ Visual Studio 2015 RC Remote Debugger, you can see the connection status.

Visual Studio 2015 RC Remote Debugger
And finally the application is deployed to the virtual machine.

Application Deployed to Remote
Happy Coding.