Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for January, 2010

SEO via IIS and ASP.NET 4

IIS_SEO_toolkit_asp.net Why SEO?

Search engine optimization (SEO) is important for any publically facing web-site.  A large percentage of traffic to sites now comes from search engines, and improving the search relevancy of your site will lead to more user traffic to your site from search engine queries (which can directly or indirectly increase the revenue you make through your site).

IIS SEO Toolkit (Search Engine Optimization Toolkit)

The SEO Toolkit helps you improve your Website’s relevance in search results by recommending how to make your new or existing site content and structure more search engine-friendly. It works on any Website on the Web. Best of all – it’s a small, lightweight free download!

ASP.NET 4 SEO Improvements

ASP.NET 4 includes a bunch of new runtime features that can help you to further optimize your site for SEO.  Some of these new features include:

  • New Page.MetaKeywords and Page.MetaDescription properties
  • New Response.RedirectPermanent() method
  • New URL Routing support for ASP.NET Web Forms

You can use the above routes and methods for both ASP.NET Web Forms and ASP.NET MVC based URLs.

ASP.NET 4 includes a bunch of feature improvements that make it easier to build public facing sites that have great SEO.  When combined with the SEO Toolkit, you should be able to use these features to increase user traffic to your site – and hopefully increase the direct or indirect revenue you make from them.

Polyglot Programming Languages in .NET

A polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independently of the programming language used to compile or interpret it.

Generally polyglots are written in a combination of C (which allows redefinition of tokens with a preprocessor) and a scripting programming language such as Lisp, Perl or sh.

For the past few years, many industry leaders were saying that developers needed to know multiple languages. They were right, because learning multiple languages (if done correctly) meant that you needed to learn different programming idioms: procedural programming, object oriented programming, functional programming, and so on.

But that’s painful. Why should I need to learn new syntax to use new idioms? Curly braces aren’t allowed in FP? semicolons aren’t permitted in dynamic languages?

Instead, why can’t a general purpose programming language support multiple programming idioms? C#, VB.NET, and C++ are starting to seriously support that. (Other languages may be doing this as well; I don’t know). All these languages have added (or are adding) lambda expressions which support functional programming concepts. (C++ has used Class Type Functors for this purpose for some time). C# is adding support for dynamic typing (as is VB.NET, in a more strict fashion than previously supported). Implicit typing is supported in C#, C++, and VB.NET as well.

This trend will continue as more and more developers want to use the best programming idiom for a particular task without learning a totally different syntax. Any programming language that calls itself a “general purpose language” will support multiple idioms.

Current .NET Version Penetration

The bad news is that only 52.7% of the users has .NET Framework 3.5 installed on their PCs, but as you can see from the table they become more and more very fast:

  Mar-08 Jun-09 Aug-09 Oct-09
Dot Nothing 28.12% 25.60% 25.53% 21.40%
.NET 1.0 2.59% 0.60% 0.40% 0.30%
.NET 1.1 23.22% 13.00% 8.41% 7.70%
.NET 2.0 27.41% 23.20% 23.02% 11.60%
.NET 3.0 17.67% 14.40% 10.01% 6.30%
.NET 3.5 0.99% 21.82% 32.63% 52.70%

jQuery hoverImage plugin

   1: (function($) {

   2:     $.fn.extend({

   3:         hoverImage: function(options) {

   4:             var defaults = { src: "-hover", preload: true, replaceEnd: "" };

   5:             options = $.extend(defaults, options);

   6:  

   7:             var append = options.src.indexOf(".") == -1;

   8:  

   9:             var splitter;

  10:             if (append) {

  11:                 splitter = options.replaceEnd + ".";

  12:             }

  13:  

  14:             return this.each(function() {

  15:                 var obj = $(this);

  16:                 var img = obj.is("[src]") ? obj : obj.children("[src]:first").eq(0);

  17:  

  18:                 if (!img.is("[src]")) {

  19:                     return true;

  20:                 }

  21:  

  22:                 var oSrc = img.attr("src");

  23:                 img.data("oSrc", oSrc);

  24:  

  25:                 var hSrc = options.src;

  26:                 if (append) {

  27:                     hSrc = oSrc.split(splitter).join(hSrc + ".");

  28:                 }

  29:                 

  30:                 img.data("hSrc", hSrc);

  31:  

  32:                 if (options.preload) {

  33:                     new Image().src = hSrc;

  34:                 }

  35:  

  36:                 obj.hover(function() { img.attr("src", img.data("hSrc")); },

  37:                           function() { img.attr("src", img.data("oSrc")); });

  38:             });

  39:         }

  40:     });

  41: })(jQuery);

Here’s a sample of html in which the plug-in is used.

   1: <html xmlns="http://www.w3.org/1999/xhtml">

   2: <head runat="server">

   3:     <title>hoverImage test page</title>

   4:     <script src="/ClientScript/jquery-1.3.2.min.js" type="text/javascript"></script>
   1:  

   2:     <script src="/ClientScript/jquery.hoverImage.js" type="text/javascript">

   1: </script>

   2:  

   3:     <script type="text/javascript">

   4:         $(function() {

   5:             $(".standardImage").hoverImage({replaceEnd: "-standard"});

   6:             $(".hoverImage").hoverImage();

   7:         });

   8:     

</script>

   5: </head>

   6: <body>

   7:     <form id="form1" runat="server">

   8:     <div>

   9:         <img class="standardImage" src="Imgs/button-standard.gif" />

  10:         <img class="hoverImage" src="Imgs/button.gif" />

  11:         <a class="hoverImage" href="#" style="display:block; width:100%;border:solid 1px black;">

  12:             <img src="Imgs/button.gif" />

  13:         </a>

  14:     </div>

  15:     </form>

  16: </body>

  17: </html>

Happy 2010~~

Useful web infrastructures, .Net development toolkits

  • Rabbit MQ – Rabbit MQ is a scalable message/queue AMQP server with WCF/C# client (free)
  • Twillio – This is an awesome commercial programmable VOIP infrastructure. Free accounts available (commercial)
  • ejabberd – This is one really scalable jabber/XMPP server (free)
  • fyiReporting – This is a free reporting tools for .Net based on Report Definition Langauge (RDL) (free)
  • Dotnet OpenID – C# library for OpenID authentication (free)
  • Tweetsharp – An excellent library for Tweeter API (free)
  • XML-RPC.Net – This is *the* library to make XML-RPC calls (free)
  • Jabber-net – This is the only client library for Jabber/XMPP protocol
  • Mono RelaxNG Validator – This is the most viable RelaxNG validator reader for .Net (free)
  • Quartz. Net – Enterprise job scheduler for .Net (free)
  • Topshelf – Windows service application framework (free)
  • Facebook Developer Toolkit – If you want to develop a Facebook App on .Net, use this (free)
  • Gitsharp – Library for Git version control (free)
  • SharpSVN – A library for Subversion Client API (free)
  • Math.NET – A mathematical open source (MIT/X11, LGPL & GPL) library written in C#/.Net, aiming to provide a self contained clean framework for symbolic algebraic and numerical / scientific computations. (free)
  • Linq to Twitter – Linq to Twitter
  • Sharp SSH – SSH Implementation in C#