Access Forbidden: Too many users are connected to Internet Information Services

This error occurs a lot on a Windows XP machine when running websites. This is because Microsoft have built in a limit of 10 connections into the XP IIS.

This limit can be bumped to 40 connections by using the ADSUTIL.vbs script.

The script is located in your C:\WINDOWS\ServicePackFiles\i386\ folder.

To bump the connection to 40, use the following:

adsutil set w3svc/MaxConnections 40

You can also disable the HTTP Keep-alives in your IIS. It reduces performance but since your machine is a developer machine anyway it probably doesn’t matter.

Sitecore : Changing language removes your parameters

Sitecore 4 have the simplest way of choosing language. Just add a link with the parameter ?lg=language (where language is the language to switch to, DA for example).

Many of my websites is multilanguage sites. At the top of each page I have thses “Change language” links listed:

<a href="?lg=da">Danish</a>
<a href="?lg=en">English</a>

But what happens if the page itself is called with parameters? The messageboard for example gets the post id as parameter. In this case my language links will make the page fail.

I developed this small function that returns all current parameters formatted as a new querystring so the parameters can be appended to my links:

using System.Web;
using System.Text;
public static string Parameters(bool firstParameterAvailable)
{
  string Exclude = "[path][layout][lang]";
  StringBuilder sb = new StringBuilder();
  NameValueCollection qs = HttpContext.Current.Request.QueryString;
  foreach (string s in qs.AllKeys)
  {
    if (Exclude.IndexOf( "["+s+"]" ) == -1)
    {
      if (sb.Length == 0 && !firstParameterAvailable)
        sb.AppendFormat("?{0}={1}", s, qs[s]);
      else
        sb.AppendFormat("={1}", s, qs[s]);
    }
  }
  return sb.ToString();
}

I then include the function in an XslExtension class and can then use it from my XSLT code:

<a href="{Parameters(1)}">UK</a>

Intelligent clipping routine

This is an intelligent text-clipping routine. If the text if too long it tries to clip out the last words of the text string untill the length is shorter than the designated length.
If there is no more spaces and the text is still too long it truncates the remaining word untill the length is below maximum.

public static string Clip(string Text, int Length, bool Ellipsis)
{
  if (Text.Length <= Length)
    return Text;
  while (Text.Length > Length)
  {
    int lastSpace = Text.LastIndexOf(" ");
    if (lastSpace == -1)
    { 
      if (Ellipsis)
        return Text.Substring(0, Length) + "...";
      return Text.Substring(0, Length);
    }
    Text = Text.Remove(lastSpace, Text.Length-lastSpace);
  }
  if (Ellipsis)
    return Text + "...";
  return Text;
}

The “Ellipsis” parameter appends epplisises (…) to the concatenated string.

.NET 2.0, Sitecore 5.2, Client Side validation and web.config

Some information about .NET 2.0 and client side validation.

As opposed to .NET 1.1, .NET 2.0 does not rely on ready-made .js files in the aspnet_client folder in order to make client side validation.

Instead the files is made run-time. .NET 2.0 does this by adding a reference to a webresource.axd file in the root of the web site.
The .js is generated by this axd so that it matches the browser and the controls on the page. The reference can look like this:

/WebResource.axd?d=v2zu1x_e9XWGPplypDt89w2&t=632745541192187789

In order for this to work with Sitecore 5.2, you must add the WebResource.axd to the IgnoreUrlPrefixes in the web.config:

setting name=”IgnoreUrlPrefixes”
value=”/trace.axd
/sitecore/shell/Editor
/sitecore/admin/upgrade
/UnhandledException.aspx
/WebResource.axd

The setting should be set by Sitecore as standard, but it is not yet so. So until that happens, remember to set it yourself, or you will get an “WebForm_PostBackOptions is undefined” error on pages using validators.