Monday, January 16, 2012
#
Tuesday, January 10, 2012
#
Once you upgrade to the Windows Azure SDK 1.6 you also get the updated Microsoft Service Bus assemblies (version 1.6.0.0) that you can use for working with Windows Azure Service Bus (yeah, no longer AppFabric Service Bus)
One of the standard implementations of Service Bus is to use the CredentialType, Credentials (the service bus namespace and the issuer key and issuer name) to create the service bus namespace URI.
Once you upgrade to Windows Azure Service Bus (Microsoft.ServiceBus) version 1.6.0.0, the following are the errors you might encounter. These are rather warnings.
'Microsoft.ServiceBus.TransportClientCredentialType' is obsolete
'Microsoft.ServiceBus.TransportClientEndpointBehavior.CredentialType' is obsolete: '"This property is deprecated. Please use TransportClientEndpointBehavior.TokenProvider instead."'
'Microsoft.ServiceBus.TransportClientEndpointBehavior.Credentials' is obsolete: '"This property is deprecated. Please use TransportClientEndpointBehavior.TokenProvider instead."'
'Microsoft.ServiceBus.TransportClientEndpointBehavior.Credentials' is obsolete: '"This property is deprecated. Please use TransportClientEndpointBehavior.TokenProvider instead."'
While this is nicely documented in the release notes, the new equivalent for this is Token Provider. So here below is a sample implementation code which uses Token Provider and TransportClientEndPointBehaviour namespaces.
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "SERVICE NAME”);
// create the credentials object for the endpoint
TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
TokenProvider tokenProvider = tokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);
sharedSecretServiceBusCredential.TokenProvider = tokenProvider;
// create the channel factory loading the configuration
ChannelFactory<IDirectoryService> channelFactory = new ChannelFactory<IDirectoryService>("DirectoryEndpoint", new EndpointAddress(serviceUri));
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
Cheers!!!
I have been working on Windows Azure Service Bus for the recently concluded Azure Camps
Yes, it is no longer referred as “Windows Azure AppFabric Service Bus”. All the 3 components i.e. Service Bus, Access Control and Caching are hereinafter referred to as simply Windows Azure Service Bus, Caching & Access Control Service, to minimize the complexity in referring to them.
Also, Service Bus and the related releases usually come as an out of bound release and are usually behind in terms of the Windows Azure SDK releases. The Windows Azure SDK latest release is the 1.6 version and along with, there is also a new version of the Service Bus. Earlier, the Service Bus assemblies sit inside the C:\Program Files\Windows Azure AppFabric SDK folder.
With the 1.6 version of the release of SDK, the Service Bus assemblies also sit inside the regular Windows Azure SDK folder. Therefore, you can find the latest version of Service Bus i.e. Microsoft.ServiceBus sits inside C:\Program Files\Windows Azure SDK\v1.6\ServiceBus\ref folder.
Similarly, the Caching assemblies sit inside C:\Program Files\Windows Azure SDK\v1.6\Cache\ref folder.
The latest version of ServiceBus is hence 1.6.0.0 and hence if you are installing, you need to make sure you update the assembly version in the config files.
Otherwise, you would typically get the wrong assembly referenced error, as follow
Exception type: System.Configuration.ConfigurationErrorsException
Message: Configuration binding extension 'system.serviceModel/bindings/netTcpRelayBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Particularly, if you are using the http://www.microsoft.com/download/en/details.aspx?id=19925 Azure AppFabric samples, they reference the older version of the assembly. And you need to update them. The release notes http://msdn.microsoft.com/en-us/library/windowsazure/hh667331.aspx covers pretty much line by line on the binding changes to be included in the config file.
So, now, whether you develop for Windows Azure Hosted Services, Storage Services or Windows Azure Service Bus you need to install, just one SDK and all of them reside under the C:\Program Files\Windows Azure\SDK folder.
In my subsequent post, I want to cover a specific deprecated assembly, its implementation and the new equivalent.
Cheers !!!
Wednesday, December 21, 2011
#
The opinions mentioned herein are solely main and do not reflect those of my employer in any way...
Monday, December 19, 2011
#
Tuesday, December 13, 2011
#
I was playing with the new Membership API (System.Web.Providers) for the upcoming
Virtual TechDays
While I was trying out a lot of options for using as DB store, one of the obvious choices was SQL Azure. With SQL Azure, I could offload the Database hosting capabilities to Azure and just focus on my application code. Of course, it comes at a cost and SQL Azure is a subscription based database available in different sizes and rates there of.
One of the challenges I faced was, working with the Membership API’s connectionstring called as “DefaultConnection”. The Default Connection is something you would use simply for all connection strings once you upgrade the application to use the New Membership API. While configuring the connection string, I copied an existing connection string of SQL Azure and changed just the database name.
The new Membership API is supposed to create the database if it doesn’t exist and then use it for creating tables for storing users, roles, etc., It failed!!
The error precisely I got was the title i.e. “EFProviders require MultipleActiveResultSets=True for System.Data.SqlClient connection strings.”
I was doubly sure that the attribute existed in connection string and moved it around, as much closer to the other attributes i.e. User Id, Database name etc., Still no luck.
This connection string had earlier worked with SQL Azure in another application earlier and I was also damn sure about it. The only difference was that application wasn’t using the new Membership API.
Then, I changed the case of the attribute (lowercase) to camel case to make it “MultipleActiveResultSets” and voila, it worked!!
I couldn’t believe that this was the problem but eventually figured that, indeed it was
So, if you hit the above error and are sure that the attribute exists, make sure, it is of pascal case. The Membership API doesn’t like it in other formats
Cheers!!!
Thursday, November 17, 2011
#
This is the 5th post in the series of HTML5 for ASP.NET Developers
Support for HTML5 in Visual Studio 2010 has been quite good with Visual Studio Service Pack 1
However, HTML5 Boilerplate template has been one of the most popular HTML5 templates out in the internet. Now, there is one for your favorite ASP.NET Webforms as well as ASP.NET MVC 3 Projects (even for ASP.NET MVC 2). And its available in the most optimal place, i.e. NuGet.
Lets see it in action. Let us fire up Visual Studio 2010 and create a “File – New Project – ASP.NET Web Application” and leave the default name to create the project. The default project template creates Site.Master, Default.aspx and the Account (membership) files.
When you run the project without any changes, it shows up the default Master Page with the Home and About placeholder pages.

Also, just to check the rendering on devices, lets try running the same page in Windows Phone 7 Emulator. You can download the SDK from here

Clearly, it looks bad on the emulator and if we were to publish the application as is, its going to be the same experience when users browse this app.
Close the browser and then switch to Visual Studio. Right click on the project and select “Manage NuGet Packages”

The NuGet Package Manager dialog opens up. Search for HTML5 Boilerplate. The options for MVC & Web Forms show up. Click on Install corresponding to the “Add HTML5 Boilerplate to Web Forms” options.
It installs the template in a few seconds. Once installed, you will be able to see a lot of additional Script files and also the all important HTML5Boilerplate.Master file.

This would be the replacement for the default Site.Master. We need to change the Content Pages (Default.aspx & other pages) to point to this Master Page. Example <%@ <% Master Language="C#" AutoEventWireup="true" CodeBehind="Html5Boilerplate.Master.cs" Inherits="WebApplication14.SiteMaster" %> would be the setting in the Default.aspx Page.
You can do a Find & Replace for Site.Master to HTML5Boilerplate.Master for the whole solution so that it is changed in all the locations.
With this, we have our Webforms application ready with HTML5 capabilities. Needless to say, we need to wire up HTML5 mark up level code, canvas, etc., further to use the actual HTML5 features, but even without that, the page is now HTML5’ed. One of the advantages of HTML5 (here HTML5 is collectively referred for CSS3, Javascript enhancements etc.,) is the ability to render the pages better on mobile and hand held devices.
So, now when we run the page from Visual Studio, the following is what we get. Notice the site.icon automatically added. The page otherwise looks similar to what it was earlier.

Now, when we also check this page on the Windows Phone Emulator, here below is what, we get.

As you can see, we definitely get a better experience now. Of course, this is not the only HTML5 feature that we can use. We need to wire up additional code for using Canvas, SVG and other HTML5 features. But, definitely, this is a good starting point.
You can also install the HTML5boilerplate Template for your ASP.NET MVC 3 and ASP.NET MVC 2 from the NuGet packages and get them ready for HTML5.
Cheers !!!
Thursday, November 03, 2011
#
One of the cool things about HTML5 is the ability to play audio/video files out of the box without the dependency on plugins. Earlier I had written about HTML5 Video and the fallback using Silverlight for non-supported scenarios
Visual Studio 2010 SP1 has decent support for HTML5, in terms of intellisense, validation etc., But, one issue that is constantly faced when using the HTML5 Video tag in an ASP.NET Application (Web/MVC) built using Visual Studio is that, the videos doesn’t play when running the application from Visual Studio on IE9.
Taking a step back, Visual Studio uses ASP.NET Development Server as the default setting when debugging and running applications on the local machine. The ASP.NET Development Server (also called as Cassini) has been there ever since Visual Studio 2005 days.
So, I created a simple MVC Application with “File – New - Project – ASP.NET MVC 3 Web Application” and left the defaults to create an Application. I added a videos folder and added a H.264 encoded mp4 video (one of the supported HTML5 Video formats) inside the folder.
Then, I added the following line of code in the “Index.cshtml” file.
<video src="@Url.Content("~/Videos/video.mp4")" id="myVideo" controls ></video>

All I got was the above. Basically a broken link. I verified that the path is right and the video is indeed playable on Windows Media Player etc.,
The issue was that, since by default Visual Studio uses the ASP.NET Development Server and the ASP.NET Development Server doesn’t have the flexibility to configure MIME types, It doesn’t understand the video format and hence could not play. When I ran the application on IE9 and checked the Network Tab of the Developer Toolbar, all I got was what you see below

I switched the Project to use IIS Express using “ProjectName” – Right Click – Properties – Web Tab

Still had the same result. Since IIS Express also doesn’t have the MIME Type to play video, configured by default, it couldn’t recognize the video and couldn’t play it.
The simple option is to configure it to use the “Actual IIS” (in the above screen, remove the check from “Use IISExpress”) which can play the video.
But, thankfully this blog post has steps on how to configure MIME types for IIS Express. Only thing is, I had to change it for configuring the MIME type for playing MP4 video.
So, the steps are
1. Click on Start button
2. Type CMD
3. Right click on the CMD that is listed and choose “Run as Administrator”
4. Do a cd to navigate to the IIS Express directory CD “Program Files (x86)”\”IIS Express”
5. And then run the following command
appcmd set config /section:staticContent /+[fileExtension='.mp4',mimeType='vieo/mp4']
That’s it. When I re-ran the application, it could play the video.

Please note, I was unable to configure or figure out how to do it for the ASP.NET Development Server. So, if we need to play HTML5 Video from Visual Studio we either need to use IIS Express or use the full fledged IIS. And from the performance and configuration perspective IIS Express offers a lot more than ASP.NET Development Server and hence it makes more sense to use IIS Express for local development.
Cheers !!!
Tuesday, November 01, 2011
#
Much has been the expectation about Silverlight 5 ever since the fire-starter in December 2010
Silverlight 5 has been the expectation of every SL developer ever since the SL4 release and the huge momentum surrounding HTML5 on the web. While HTML5 is definitely promising, Silverlight and other proprietary plugins have their own strengths in terms of rich capabilities such as Digital Rights Management which have evolved to a great extent.
In MIX 2011, Scott Guthrie unveiled Silverlight 5 Beta among much fanfare! You can read about the complete list of Silverlight 5 Beta features
In the meantime, Silverlight 5 RC is available for download from here
Cheers !!!
Wednesday, October 26, 2011
#
If you are active on Facebook, there is very less chance that you missed on the recent Facebook UI update “Social Graph” or more popularly referred as “Timeline” (a screenshot of how the Timeline profile UI looks, here below)

This Timeline UI has been quite popular and is supported in most of the modern browsers including IE9, Chrome 14 & Firefox 6 and above.
I am a power consumer of web and use IE9 as my primary browser. Timeline UI works excellent in IE9.
I have also downloaded the IE10 Platform Preview for Windows 7, which provides greater support for some of the HTML5 standards.
Also, with Windows Developer Preview ships the IE10 Developer Preview (a newer version after IE10 PP2). This has the best possible support for CSS3 transitions and other latest web standards.
Both in IE10 PP2 and IE Developer Preview, Facebook Timeline UI doesn’t show up. It shows the classic view although I have enabled timeline. Gut feel is, they are doing browser sniffing and with the user agent not enabling the Timeline for not matching major version 9 in case of IE. Actually IE10 PP2 and Developer Preview have better support for CSS3 and other new web standards. So, to enable Timeline UI in IE10 PP2 or the IE Developer Preview shipped in Windows Developer Preview, we need to use the IE Developer Toolbar (press F12)
So, here is the view of Facebook Profile in IE Developer Preview which features by default Browser Mode IE10.

Once we change the browser mode to IE9, I get the social graph view as below

I tested the same in both IE10 Developer Preview (Windows Developer Preview) and IE10 PP2 (Windows 7) and got the desired results 
Goes on to prove my earlier posts on how the Developer Toolbar in IE is very helpful for Developers.
And here is a nice video on how to enable Facebook Timeline for your account.
I think it is these little nifty changes that separates we developers from the regular consumers 
Cheers !!!
I am playing more with the Windows Developer Preview and simply love the backward compatibility it has for applications that used to work in Windows 7. And one of the applications critical to my day-to-day life is Visual Studio. Visual Studio 2010 with SP1 and ASP.NET MVC 3 Tools is my everyday requirement.
Windows Developer Preview when installed from the MSDN Center has two flavors. One with the Developer Tools which I would assume, most of us developers would want and the other one, which is simply the Windows Developer Preview (without the Tools).
And the Tools that it ships with has a version of VS11 Developer Preview which is just for building Metro Style applications. If you plan to use the same for web development (using MVC or Web Forms) you need to install a separate version of VS11. I had blogged about this earlier
I was setting up Windows Developer Preview as my primary development machine so in addition to VS11, I also required VS 2010 to be installed. So, I installed VS 2010 and the SP1. Post that I was trying to install MVC 3 for VS 2010. It simply took a long time and then rolled back the installation 
I tried couple of times just to repro and found the same results.
The interesting thing is, MVC3 for VS11 installed happily on the machine. (MVC 4 was already installed)
When I checked with Phil Haack and Jacques Eloff they neatly helped me with this. Essentially MVC 4 has a newer version of NuGet installed and that was preventing MVC 3 for VS 2010 to be installed. The steps to resolve are quite simple.
Uninstall NuGet from Add/Remove Programs.
Install MVC 3 for VS 2010 from here
That’s it. It would automatically reinstall the NuGet.
If this post was confusing like my earlier post read it again 
Cheers !!!
Monday, October 17, 2011
#
UPDATE
The below sample just showcases the locality sample. The complete set of attributes exposed which include PostalCode, CountryRegion, Address etc., are available at http://msdn.microsoft.com/en-us/library/ff701710.aspx
This is the third in the series of posts I am doing on HTML5 for ASP.NET Developers
Geolocation is one of the popular features of HTML5 that’s being touted as a favorite for building location aware applications. It helps to a great extent not just for Web Applications that run on PCs, but also for Web Applications that run on Devices. Since browser on the phone is no longer a rare thing, it always helps to identify the location of the user carrying the phone and build applications that cater to the specific geo (example: providing deals available nearby etc.,)
The actual call required for our sample is quite simple. Geolocation works only on IE9 and above. So, if you haven’t installed already, you can download and install IE9 from here
For the sake of our sample, lets create an ASP.NET Web Forms Application using Visual Studio 2010 (File – New – Project – ASP.NET Web Application)
By default it creates a Site.Master and Default.aspx page which inherits from the master page. Also, jQuery is included as a part of the scripts. So, lets pull the jQuery files on to the Master Page.
So, as of now, I have opened up the Site.Master and also expanded the Scripts folder in the project explorer and dragged the jQuery-1.4.1.min.js file onto the Site.Master

Then, open up the Default.aspx page and add the following lines of code
<input type="button" id="btnFindMyLocation" value="Find My Location" />
<input type="text" id="txtLocation" />
The Geolocation API provides the Latitude and Longitude co-ordinates. Using that, we would like to get the current location by using the Bing Maps SDK. Hence, we need a Bing Maps SDK token. It can be obtained from http://www.bing.com/toolbox/bingdeveloper/
Click on “Sign-in Bing Maps” and use existing Live ID credentials. Once signed-in, it asks you a few details. Fill out those details and then it presents a dashboard. On the top left menu, you can find the “Create or View Keys”.
Click on it, and follow the steps to get the token. Your token would be typically a GUID of considerable length. This we would need to pass on to the SDK and get the location.
Coming back to our Default Page, add the following snippet somewhere above the input tags which we added earlier.
<script type="text/javascript">
$(function () {
$("#btnFindMyLocation").click(function () {
// find lat/long with geo api
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (pos) {
// query city from Bing Maps API
var url = "http://dev.virtualearth.net/REST/v1/Locations/" + pos.coords.latitude + "," + pos.coords.longitude + "?&key=REPLACE YOUR BING MAP SDK KEY";
$.ajax({
url: url,
dataType: "jsonp",
jsonp: "jsonp",
success: function (data) {
$("#txtLocation").val(data.resourceSets[0].resources[0].address.locality);
}
});
}, function () {
alert("Unable to find your location");
});
} else {
alert("Your browser does not support GeoLocation API! ");
}
});
});
</script>
Make sure you change the RED text in the code above with the actual Bing Maps SDK Key that you obtain from the Developer Portal. Once this is done, you can run the page. It presents an UI as below:-

Click on “Find My Location” and you would see a warning in the below as follows:-

Click on “Allow Once” and then it reloads the page and then fills up the TextBox with your current location.

So, with few simple steps, we can find the actual location of the users through the Geolocation API and using Bing Maps SDK.
Cheers!!!
This would be the first in the series of posts I plan to do for HTML5 for ASP.NET Developers The first thing that everyone would have experienced is the HTML5 header tag.
The regular header tag that Visual Studio creates for ASP.NET Webforms is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
This would be the header tag present in the Master Page or the actual ASPX Page when you don’t inherit from a Master Page. Till HTML5 specifications started momentum, the general DOCTYPE was this lengthy and makes it hard to really remember. It also indicates a bit of versioning to HTML.
With HTML5, the header changes simply to
<!DOCTYPE html>
You would notice this tag quite prominently in all HTML5 conferences and articles.
Also, when you create an ASP.NET MVC 3 project using Visual Studio 2010, you would notice that this is the default header tag in your Layout.cshtml page (equivalent of Master Pages for MVC3)
Strictly speaking this tag is not mandatory for using other HTML5 tags. But having this would mean or decipher to the browser that this page uses HTML5 features.
Going forward VS11 and other project types would have this default header tag but as of now, we can modify our page header and simply put <!DOCTYPE html>
One interesting thing which was identified by my friend and team mate Rajasekharan Vengalil is that, if we remove the tag completely, the Internet Developer Toolbar defaults to Quirks Mode since its unable to find a DocType. The IE Developer Toolbar is a wonderful utility for web developers for testing, debugging and doing a variety of tasks. I had written a bunch of posts earlier on this here, here & here Plan to write more of these in near future 
To demonstrate this behavior, lets fire up Visual Studio 2010 and create a File – New Project – ASP.NET Web Forms Application. Just leave the defaults and let the site be created.
I would assume you are running the IE9 as your default browser. If you haven’t installed it yet, you can download it from here
Lets open up the Site.Master. We will find in the top the default XHTML 1.0 strict doctype. Lets remove this header and then run the page. Once IE opens up with the Default Page, press F12 or choose “F12 developer tools” from the Tools menu in the right top.

Once it opens up, you would notice the following for “Browser Mode” and “Document Mode”

As you can see, it defaults to “Quirks Mode”. Here is a nice post from the IE Team on Document Modes and Browser Modes but, simply putting, Quirks mode is JavaScript behavior of IE6.
So, we need to have DocType mentioned in the Master Page or Layout Page. And all the more good, if we simply change it to <!DOCTYPE html>
Next, we will jump into some advanced stuff and then come back to the mark up enhancements.
Cheers !!!
HTML5 for ASP.NET Developers is my attempt to learn HTML5 myself being an ASP.NET Developer. I am planning to post a series of posts on how ASP.NET Developers can leverage some of the HTML5 features in their applications. To begin with, I plan to post a few samples on the following
1. Markup Enhancements that every ASP.NET Developer should know
2. Using HTML5 Geolocation API
3. Using HTML5 Local Storage in ASP.NET Applications
4. Making HTML5 Video work with IIS Express
5. HTML5 Boilerplate template for ASP.NET with Visual Studio 2010
6. Playing HTML5 Video with fall back for IE8/IE7 and earlier versions of other browsers using Silverlight
And few other things (I will update the above links as and when I get more posts)
In the meantime, it doesn’t need more reiteration that HTML5 is a critical learning for every web developer be it you work on ASP.NET or PHP for web development.
Cheers !!!