Web Technology

Web browsers and things on the web

Finally an AWESOME competition for South African Developers

Submitted by Robert MacLean on Wed, 01/12/2011 - 10:12

logoI often find too many competitions from Microsoft ignore the southern tip of Africa or focus on specific markets, like education with the great ImagineCup event. Finally us hard working developers get a great competition: Internet Explorer 9 Top Developer Competition

This competition wants* developers to either create an awesome IE 9 add-on or light up a web site with some of the new awesome IE 9 features – so if you a web dev, html monkey, C++ or .NET developer you can take part!

The prize? A trip to PDC – the conference were two years ago everyone got hand build super laptops and last year Windows Phone 7 devices**, not to mention it is where the top Microsoft development speakers meet!

So get coding, you only have until March!!

Some things you may want to check out:

* Side note: “The competition wants” really sounds like the competition is a living entity and will punish you if you don’t do this… it isn’t and it won’t.

** My guess for this year at PDC is giving everyone tablets - just looking at what was announced at CES.

Internet Explorer 9 breaks with localhost

Submitted by Robert MacLean on Thu, 10/07/2010 - 08:49
There is a known bug for this 601047 This is resolved with RTM!
You can hear Eric Lawrence talk about this bug in the Herding Code Podcast

Internet Explorer 9 works great, except when it doesn’t, and it seems to not work for developers more than most, or maybe it’s just me (could the IE9 team be targeting me?).

Paranoia aside, there is an issue where when testing web applications (ASP.NET, MVC) or Silverlight applications from Visual Studio (i.e. press F5) it just refuses to load. Thankfully this has been confirmed by other people Winking smile

image

What is going on and how do we solve this? Because it is really frustrating and it also makes for bad demos (especially with TechEd around the corner).

The first part of the problem is the ASP.NET Development Server which is what is hosting your websites when you hit F5.

image

Next part of the problem is Windows, especially since it assumes IPv6 is better than IPv4. Note in the picture below that when you ping localhost you get an IPv6 address.

image

So what appears to be happening is when IE9 tries to go to localhost it uses IPv6, and the ASP.NET Development Server is IPv4 only and so nothing loads and we get the error.

To solve this fire up notepad in administrator mode and navigate to <windows directory>\system32\drivers\etc\ and open the hosts file. Inside you will find a number of lines prefixed with a hash (which makes those lines comments). Remove the hash from the line which has 127.0.0.1 in it, as below and save.

image 

This will cause Windows to resolve localhost to IPv4 first (you can confirm by pinging localhost) which means that IE9 will do the same and now it just works every time.

image

Redirected down a one way: Clearing the Internet Explorer host redirect cache

Submitted by Robert MacLean on Wed, 10/06/2010 - 08:51

Internet Explorer 9 is fast, really, really fast! A lot of that speed comes from the massive caching improvements in IE9 – but this is a bit of a double edge sword, especially for developers when caching gets in the way of what is actually happening. I spent two hours debugging an odd caching issue recently and this is the sad story.

For some testing I needed to setup a redirect, in this case a 301 permanent redirect (handy HTTP status codes cheat sheet in case you don’t remember these). What this would do is enable me to have site alpha (http://localhost:5000/Demo) redirect to site beta (http://localhost:9000/Demo).

Prior to this the scenario look like this:

image

Behind the two browser windows is the IE 9 Developer tools and their fantastic new network capture feature. You can easily see that when I hit site alpha I got a 200 result, meaning all good and it loaded.

Once I setup the redirect, you’ll see I get a 304 this is because the data is already cached. Note that even though I typed in the site one URL it immediately loaded site two. This is because the browser had cached the redirect and so skipped the network steps for performance.

image

Now the problem, I wanted to turn off the redirect – however the browser cached it and so would ignore the change. Clearing cache, deleting files, rebooting and even using the IE reset option did nothing to solve this Crying face 

The only way to fix it was to fire up the fantastic Fiddler tool and use it’s Clear Cache option with the option to delete persistent cookies, which flushes the WinINET cache.

image

Considering that this is supposedly the same as clearing the IE cache I have no idea why this works and IE cache clearing doesn’t but it does work.

Cannot add a Service Reference to SharePoint 2010 OData!

Submitted by Robert MacLean on Mon, 09/27/2010 - 11:22

SharePoint 2010 has a number of API’s (an API is a way we communicate with SharePoint), some we have had for a while like the web services but one is new – OData. What is OData?

The Open Data Protocol (OData) is a Webprotocol for querying and updating data that provides a way tounlock your data and free it from silos that exist in applicationstoday. OData does this by applying and building upon Webtechnologies such as HTTP, Atom PublishingProtocol (AtomPub) and JSON toprovide access to information from a variety of applications,services, and stores.

The main reason I like OData over the web services is that it is lightweight, works well in Visual Studio and works easily across platform, thanks to all the SDK’s.

Clipboard01SharePoint 2010 exposes these on the following URL http(s)://<site>/_vti_bin/listdata.svc and you can add this to Visual Studio to consume using the exact same as a web service to SharePoint, right click on the project and select Add Service Reference.

Once loaded, each list is a contract and listed on the left and to add it to code, you just hit OK and start using it.

Add Service Reference Failed

Clipboard03The procedure above works well, until it doesn’t and oddly enough my current work found a situation which one which caused the add reference to fail! The experience isn’t great when it does fail – the Add dialog closes and pops back up blank! Try it again and it disappears again but stays away.

Clipboard04If you check the status bar in VS, you will see the error message indicating it has failed – but by this point you may see the service reference is listed there but no code works, because the adding failed.

If you right click and say delete, it will also refuse to delete because the adding failed. The only way to get rid of it is to close Visual Studio, go to the service reference folder (<Solution Folder>\<Project Folder>\Service References) and delete the folder in there which matches the name of your service. You will now be able to launch Visual Studio again, and will be able to delete the service reference.

What went wrong?

Clipboard06Since we have no way to know what went wrong, we need to get a lot more low level. We start off by launching a web browser and going to the meta data URL for the service: http(s)://<site>/_vti_bin/listdata.svc/$metadata

In Internet Explorer 9 this just gives a useless blank page Sad smile but if you use the right click menu option in IE 9, View Source, it will show you the XML in notepad. This XML is what Visual Studio is taking, trying to parse and failing on. For us to diagnose the cause we need to work with this XML, so save it to your machine and save it with a .csdl file extension. We need this special extension for the next tool we will use which refuses to work with files without it.

Clipboard07The next step is to open the Visual Studio Command Prompt and navigate to where you saved the CSDL file. We will use a command line tool called DataSvcUtil.exe. This may be familiar to WCF people who know SvcUtil.exe which is very similar, but this one is specifically for OData services. All it does is take the CSDL file and produce a code contract from it, the syntax is very easy: datasvcutil.exe /out:<file.cs> /in:<file.csdl>

Immediately you will see a mass of red, and you know that red means error. In my case I have a list called 1 History which in the OData service is known by it’s gangster name _1History. This problem child is breaking my ability to generate code, which you can figure out by reading the errors. 

Solving the problem!

Clipboard09Thankfully I do not need 1 History, so to fix this issue I need to clean up the CSDL file of _1History references. I switched to Visual Studio and loaded the CSDL file in it and begin to start removing all references to the troublemaker. I also needed to remove the item contract for the list which is __1HistoryItem. I start off by removing the item contract EntityType which is highlighted in the image along side.

The next cleanup step is to remove all the associations to __1HistoryItem.

Clipboard10Finally the last item I need to remove is the EntitySet for the list:

BREATH! RELAX!

Ok, now the hard work is done and so I jump back to the command prompt and re-run the DataSvcUtil tool, and it now works: Clipboard12

Clipboard14This produces a file, in my case sharepoint.cs, which I am able to add that to my project just as any other class file and I am able to make use of OData in my solution just like it is supposed to work!

IE 8 Beta 2 - Zoom issues

Submitted by Robert MacLean on Mon, 11/24/2008 - 10:18

If you are using IE 8 beta 2 and your zoom is NOT at 100% you could be having all kinds of issues from performance to skipping around the screen and being unable to select text. This doesn’t seem to be a big issue, I mean who runs at anything other than 100% but it is bigger than that. See in IE 8 your DPI settings will effect the zoom, so if you are running 1280x1024 or higher by default you will be at 120DPI and not the standard 96DPI which means you will run at 125% zoom in IE! It also effect people using the zoom for accessibility reasons.

There are two items available for voting on for these issues on Connect, so if you are an IE 8 beta user please take the 5 min to first test yourself and if you are able to repro the issue please vote on these items:

GMail - Oh so sexy

Submitted by Robert MacLean on Mon, 11/24/2008 - 09:46

If you haven’t checked out GMail for a while, you need to today! They have launched approx 12 themes for it. That in itself isn’t impressive but the fact the themes seem MUCH faster than before and work perfectly in IE 8 Beta 2 in standards mode means that is one less site that I have to keep IE in compat mode for!

gmail2

My inbox with the new Shiny theme – after Firefly anything names Shiny gets bonus points with me.

SharePoint Search Tips and Tricks

Submitted by Robert MacLean on Tue, 11/11/2008 - 16:44

I thought I would share some tips and tricks for improving the search experience with SharePoint:

In any company you will have people of different backgrounds and skills using SharePoint, and one of the first issues is that search isn’t fine grained enough, and that users either don’t know or don’t feel comfortable with advanced search features to get it fine grained. To make “normal” search easier just add Faceted Search. If you are interested in what that is go and check out the site.

Next improve usage by lighting up SharePoint search to the browsers. Well what does that mean? It means that when you go to a website with a modern browser it “detects” the search functionality and allows you to add it to the build in search functions in your browser, so you can search the SharePoint site from your browser without even going to it first! It does this using an open standard called Open Search. To do this you first need to define an XML file which tells the browser what to do. Example:

Clipboard01

Really simple, basically just the name and the encoding. The magic is handled by replacing the tag in the URL ({searchTerms}) with what the user is searching for. That file needs to be uploaded to a location on the SharePoint site where it can be read by users. The next step is exposing it to the browsers, to do this you just need to add a line to the header tag in your master page:

   1: <link rel="search" type="application/opensearchdescription+xml" href="/search/searchdefination.xml" title="BB&amp;D Portal" />

Now the browsers will see the tag and light up the search facility! This is really helpful for improving adoption of search.

Next up it would be great to search multiple locations and you can thanks to a feature in SP 1 called federated search. Where your search query actually calls other web sites for results and places them in a special section of the site, defined by a web part. As I am personally interested in a lot of technologies I think it would be great to have federated search to: Wikipedia, Linux.Com, Java.Sun.Com, MSDN.Microsoft.Com and TechNet.Microsoft.Com, like shown on the left.

What you may notice is that MSDN already has support for federated search, but the rest don’t! So how do you get around that? Well Live.Com also does has support for federated search and it also has support for limiting results to a specific site. So all that is needed to do is to create a search provider configuration for live.com and limit it to the specified website. You can download the sample providers I created below:

Clipboard01

The last tip is to implement a very clean landing page for the site with a search box on it. As the new landing is cleaner and smaller than the it meant the initial feeling of SharePoint is it is that it is quicker and more responsive and so it also will improve adoption. To get the search box to search properly using just a tiny bit of HTML + JavaScript which looks like this (assuming you have a textbox with ID called query), this will create the button:

   1: <input type="button" width="100px" height="" value="Search" onclick="window.location='/pages/SearchResults.aspx?k='+document.getElementById('query').value+'&s=All%20Sites';">

Microsoft CRM on Linux!

Submitted by Robert MacLean on Thu, 09/11/2008 - 17:22
I work with great people who are open minded (none of this my brand is better than your brand thinking), so much so they are IMHO the driving force behind interoperability in South Africa. When I recently presented a session on Microsoft CRM and said that it couldn’t be used on other operating systems, Henk, our Linux expert, took it as a challenge to get it to work.
The main issue is that for MSCRM to work it needs Internet Explorer and it needs IE because of the million lines of JavaScript that exist and a lot of it makes use of MSXML which is not available cross platform.
Henk did some magic and found a program/tool/package called IE4Linux! What is IE4Linux?:
IEs4Linux is the simpler way to have Microsoft Internet Explorer running on Linux (or any OS running Wine). No clicks needed. No boring setup processes. No Wine complications. Just one easy script and you'll get three IE versions to test your Sites. And it's free and open source.

They mention three versions which are 5.0, 5.5 and 6.0, however 7.0 is in beta. Since MSCRM needs 5.5 or higher it just might work! Henk did his magic to get it working and I did mine (which was very easy, just making sure my VM is running and getting the firewall configured) and without much fuss he got Microsoft CRM running on Linux!!! He has promised a whole post on IE4Linux so if you want to know more please watch his site, otherwise enjoy the pictures taken from his Linux box below of MSCRM!

crm_on_linux2-blog  crm_new_contact-blog crm_movie_on_linux-blog

MSDN Library Broken

Submitted by Robert MacLean on Wed, 06/04/2008 - 19:48
So if you install the Internet Explorer 8 demo and you use Visual Studio, you will find that help gets broken. All that is happening is that the hxds.dll which dexplorer.exe needs gets provisionally blocked from running. The easiest way to fix it, is to start the MSDN library outside of Visual Studio and you should get prompted to run the add-on. If you run it, Internet Explorer will then be happy with it and the MSDN library will start to work
.

IE8 - The developers best friend

Submitted by Robert MacLean on Tue, 03/11/2008 - 08:52
There are a few good reasons to use IE 8 as a developer but yesterday I found my new favorite. When using Visual Studio 2008 and running the site a new section appears in the solution explorer called Script Documents. In this little gem of a folder is the pages you are looking at, the scripts etc... all as the server provided them to the browser! Meaning if you open the .aspx page there is no ASP controls, just normal HTML. If you do inserts of JavaScript via OnInit, that is there as well. Amazing!