Galin Iliev's blog

Software Architecture & Development

How to add Google+1 button to

After adding Facebook “Like” button to my blog I’ve decided to add Google+1 button as well Smile. I guess I am also going social although a little old fashioned with blog.

Again it is very easy to add it with two simple steps:

1. Add the tag to the template in order to appear in every post.

Open ~/themes/MY-BLOG_THEME and edit PostView.ascx by adding following script where appropriate:

<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="small" annotation="inline" href="<%=Post.PermaLink %>"></g:plusone>

2. Add google JS at the end of the page.

Open ~/themes/MY-BLOG_THEME and edit site.master and add this at the end:

<!-- Place this render call where appropriate -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

Please refer to google documentation for more information and to configurator to customize

What's New in ASP.NET 4

Since VS 2010 is out with many new features and there aren’t many books out yet to cover them I am trying to collect resources where those goodies can be learned. Here is my compilation for ASP.NET 4 new features:

Core Services
Web.config File Refactoring
Extensible Output Caching
Auto-Start Web Applications
Permanently Redirecting a Page
Shrinking Session State
Expanding the Range of Allowable URLs
Extensible Request Validation
Object Caching and Object Caching Extensibility
Extensible HTML, URL, and HTTP Header Encoding
Performance Monitoring for Individual Applications in a Single Worker Process

jQuery Included with Web Forms and MVC
Content Delivery Network Support
ScriptManager Explicit Scripts

Web Forms
Setting Meta Tags with the Page.MetaKeywords and Page.MetaDescription Properties
Enabling View State for Individual Controls
Changes to Browser Capabilities
Routing in ASP.NET 4
Setting Client IDs
Persisting Row Selection in Data Controls
ASP.NET Chart Control
Filtering Data with the QueryExtender Control
Html Encoded Code Expressions
Project Template Changes
CSS Improvements
Hiding div Elements Around Hidden Fields
Rendering an Outer Table for Templated Controls
ListView Control Enhancements
CheckBoxList and RadioButtonList Control Enhancements
Menu Control Improvements
Wizard and CreateUserWizard Controls 56

Areas Support
Data-Annotation Attribute Validation Support
Templated Helpers

Dynamic Data
Enabling Dynamic Data for Existing Projects
Declarative DynamicDataManager Control Syntax
Entity Templates
New Field Templates for URLs and E-mail Addresses
Creating Links with the DynamicHyperLink Control
Support for Inheritance in the Data Model
Support for Many-to-Many Relationships (Entity Framework Only)
New Attributes to Control Display and Support Enumerations
Enhanced Support for Filters

Visual Studio 2010 Web Development Improvements
Improved CSS Compatibility
HTML and JavaScript Snippets
JavaScript IntelliSense Enhancements

Web Application Deployment with Visual Studio 2010
Web Packaging
Web.config Transformation
Database Deployment
One-Click Publish for Web Applications

Download PDF version of this whitepaper [1.13 MB]
What's New in ASP.NET 4 and Visual Web Developer on MSDN

Getting started with Silverlight

Tim Heuer posted a great series of articles targeted a new Silverlight developers. These can be used to ramp up with new things in v3 as well as Silverlight concepts.

Original post here.

Windows 7 RTM – code fully cooked

Today Microsoft announced that Windows 7 and Windows Server 2008 R2 code is signed off and is ready to go to manufacture – so this will be the code that end user will use.

Even more - partners and business customers can get their hands on Windows 7 RTM code starting next month.

I have been using Windows 7 and Windows Server 2008 R2 since their Beta and I dare to say that this is the fastest OS, I’ve ever worked with. You will like it for sure.

Both client (Windows 7) and server (Windows Server 2008 R2) are full with improvements and for sure these increase both the pleasure and the productivity.

Office 2010 – office in the web

“Office 2010” will be official name of Office 14 and will be ready in “the first half of next year”.

Office 2010 — previously known by the code name "Office 14" — will include slimmed-down versions of Word, Excel, PowerPoint and OneNote that let people create and edit documents in a Web browser. Consumers will have access to a free, ad-supported version, and Capossela said the company is still hammering out what to charge businesses that want a version without ads.

source MSNBC

Cross-site request forgery or how dangerous REST can be if not implemented properly

A friend of mine send me link to article in Wikipedia describing Cross-site request forgery attack.

Cross-site request forgery, also known as one-click attack or session riding and abbreviated as CSRF ("sea-surf"[1]) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts.[2] Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.

(source Wikipedia)

This is how the attack is performed:

<img src="http://bank.example/withdraw?account=bob&amount=1000000&for=mallory">

Note how simple this would be?! And end user won’t see anything – not even image :).

This illustrates why is so important when implementing REST in your services to do only read on GET requests.

Finally up & running

As you might noticed this week the site was down. This was due to hosting upgrade to favorite IIS7 and some issues with dasBlog and one of it’s controls. Luckily I was able to fix it and also upgraded to dasBlog v2.2.

Hopefully there won’t be any downtime next… 10 years (next upgrade should be handled nicely :) ) Not like I am planning uptime 5 nines – 99.99999% :)

Now seriously:

If you planning your servers’ availability you might want to check how Ops are doing it by taking a consultation from them for free. Why?! Because these are the results (as of 2005) – just imagine what are now:


  • 3 Data Centers
  • 1606 Data Center Servers
  • 506 Servers in Labs
  • 111 Web Sites
  • 1069 Databases
  • 1000’s of Web Applications
  • 80+Gbit/sec Network Traffic

  • 13 million unique users/day
  • 70 million page views per day
  • 10,000 requests/sec, 300 concurrent connection on 80 servers
  • 350 Vroots

Windows Update/Download:

  • 150 million unique client scans/day
  • 12,000 ASP.NET requests/sec
  • 500K concurrent connections
  • 1 Billion Downloads and 750K client installs in 2 weeks (April 2006)
  • 4Gbit/sec Web Site Egress (Web Pages Only…No Downloads)
  • 20+ Billion Downloads in 2005…Routinely 150M+/Day

IIS 7.5 features lists

Internet Information Services 7.5 (IIS)

The great Internet Information Services (IIS) has it’s v7.5 with following features in Windows Server 2008 R2

  • PowerShell provider for IIS 7 has more than 50 new cmdlets
  • Administration Pack extensions: Database Manager (SQL Server management within IIS Manager), Configuration Editor (generate scripts with a GUI to automate administrative tasks), IIS Reports, Request Filtering (HTTP filtering, URL rewriting, etc.)
  • One-click publishing in Visual Studio 10
  • Web Deployment Tool (formerly MS Deploy): Deployment, management, and migration of Web applications, sites, and entire servers
  • Configuration Tracing: track configuration changes to IIS and applications
  • New performance counters
  • .NET support for Server Core
  • WebDav integration (was available before as a separate extension)
  • URLScan 3.0 integration: restricts the types of HTTP requests (was available before as a separate extension)
  • FTP server services: integrated in the IIS administration interface; new .NET XML-based *.config format; virtual host names for FTP sites; improved logging
  • Integrated extensions: new kind of extensions that appear to be an integral part of IIS

(via article)

Time for reinstall&hellip; .NET Framework

I had interesting issue today: I was on urge to complete a task when I saw a strange exception – you know – the Murphy's law. It hit at the most inconvenient time. To be even more interesting I’ve deployed my work on two different servers and worked fine.

But on the most important one I got this exception when I tried to hit WCF service:

System.MissingMethodException: Method not found: 'Void System.ServiceModel.Diagnostics.EventLogger.UnsafeLogEvent(System.Diagnostics.TraceEventType, System.ServiceModel.Diagnostics.EventLogCategory, System.ServiceModel.Diagnostics.EventLogEventId, Boolean, System.String[])'.
   at System.Runtime.CompilerServices.RuntimeHelpers.PrepareDelegate(Delegate d)
   at System.AppDomain.add_UnhandledException(UnhandledExceptionEventHandler value)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureInitialized()
   at System.ServiceModel.PartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state)
   at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Very strange… and search engines doesn’t know much about the problem…

Luckily this was not used heavily and I could reinstall .NET Framework 3.5. And this solved the problem.. Now back to more productive things…

ASP.NET Adjust HTML Size, UX and AJAX

Problem Introduction

You come up with a great HTML layout for data-driven ASP.NET web page which makes perfect sense from business perspective and reveals key indicators while making possible to drilldown into details if needed. This page utilizes DHTML and AJAX calls to improve User eXperience (UX) and overall page looks great until… your database is not filled up and page load time is increasing due to generated HTML size, DHTML is slow due to big DOM tree and users starting to complain about it.

Possible Solutions

At that point there are several approaches that can be employed to help:

  1. Rework page layout so only part of data is loaded;
  2. Download data to the client in XML or JSON format and generate necessary HTML code on client
  3. Load only those portions that need to be immediately displayed and load others on demand (e.g. like paging)

Let’s explore these options:

Rework layout

Here is no technical challenge here – just business one: you have to sell new layout to existing users/customers and once they liked the initial one this can be really difficult. If you can do that – go ahead. There is nothing wrong with that approach.

Client-side bindings

Instead of downloading 10 MB HTML code to client’s browser you can generate pure JSON and having a template of HTML just to fill data in the HTML template with simple (or not-so-simple) loop. Good news here is that such feature is coming to ASP.NET AJAX in v4.0. It is called client templates and implements the idea. Here are some resources:

Partially Loading Page

This is also not new concept – load only  those parts that should be visible immediately to the user. Traditional paging explores that option although it is not that fancy. If you’re using Google Reader you probably noticed that it loads only visible part of the feed and as you scroll down it keeps loading from the RSS feed.

So here is the idea: having small piece of HTML loaded would ease the browser in rendering HTML DOM tree and you gain performance. As user keeps using the page you keep adding HTML to existing DOM tree by loading it dynamically using AJAX.

Tricky part could be rendering ASP.NET User Control within Web Service so pure HTML can be returned by AJAX. Here are some useful tips:


Utilizing these techniques could improve download time for your web apps and also speed them up because the browser doesn’t need to process whole DOM before give the control to the user. All these can be used together or in any combination as long as it makes sense from business perspective.

Hope this helps!