Thursday 25 June 2009

ASP.NET 2.0 start up times

There appears to be a bug with the 2.0 framework, when a managed application that uses an Authenticode signature can take longer than usual to start. See http://support.microsoft.com/kb/936707.
Adding the following to your web.config knocked minutes off startup time.
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
Using Sitecore this trimmed up to a minute off the start up times.

Monday 22 June 2009

Webservices and HTTP Error 404.3

When viewing a new webservice setup in IIS 7, you get the following error:

HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Check that you have installed the WCF Activation component for IIS.
  1. Open Server Manager, click Start > Server Manager
  2. From the left panel in Server Manager, click on Features
  3. Click on Add Features
  4. From the available list of features, scroll down and select .Net Framework 3.0 Features and then WCF Activation, then click Next
  5. On the Confirmation page, click on Install
  6. Installation of the selected feature will be initialized and started
  7. Once installation is completed, click on Close

JavaScript Compression in IIS 7

In IIS 7.0, the HTTP compression is configured in the ApplicationHost.config file (c:\windows\system32\inetsrv\config\applicationhost.config.
<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="0">  
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
Anything that starts with the MIME type of text or message will be compressed, but it maps only a single javascript mime type to be compressed, application/javascript.

However, the default mappings in the ApplicationHost.config are set to:

<mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
<mimeMap fileExtension=".jsx" mimeType="text/jscript" />


As you can see, the MIME type for JavaScript files is set to application/x-javascript, which is not the same as the default in the compression section above. To solve this, you need the add the MIME type application/javascript, to your Web.config.
<system.webServer>
...
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
</staticContent>
</system.webServer>

Friday 19 June 2009

Telnet on Vista and Windows Server 2008

By default, Vista and Windows Server 2008 don't have telnet installed. You end up with the error if you try to run telnet.

'telnet' is not recognized as an internal or external command,operable program or batch file.

To solve:
Windows Server 2008
  1. Open Server Manager, click Start > Server Manager
  2. From the left panel in Server Manager, click on Features
  3. Click on Add Features
  4. From the available list of features, scroll down and select Telnet Client, then click Next
  5. On the Confirmation page, click on Install
  6. Installation of the selected feature will be initialized and started
  7. Once installation is completed, click on Close
Vista
  1. Open Control Panel, click Start > Control Panel
  2. Select Programs and Features
  3. Click on Add Features
  4. Select Turn Windows features on or off.
  5. Select the Telnet Client option.
  6. Click OK.

Friday 12 June 2009

Sitecore XHTML Validation - Attribute "name" exists, but can not be used for this element

If using XHTML 1.0 Strict and the site doesn't validate with the error "Attribute "name" exists, but can not be used for this element" See my previous post, check that you have added the following line into the web config in system.web
<xhtmlConformance mode="Strict" />

If you have done the above and you site if now valdiating locally, but not when using the w3c validator, this is because the w3c service uses a down level browser and the HTML that is generated doesn't comply to the standard that the DOCTYPE needs.

To solve this problem, you need to add a new .browser file in the App_Browsers directory. Just create a new file called w3cvalidator.browser and copy in the following code:
<browsers>  
  <!--  Browser capability file for the w3c validator  
        sample UA: "W3C_Validator/1.305.2.148 libwww-perl/5.803"  
  -->  
  <browser id="w3cValidator" parentID="default">  
    <identification>  
      <userAgent match="^W3C_Validator" />  
    </identification>  
  
    <capture>  
      <userAgent match="^W3C_Validator/(?'version'(?'major'\d+)(?'minor'\.\d+)\w*).*" />  
    </capture>  
  
    <capabilities>  
      <capability name="browser" value="w3cValidator" />  
      <capability name="majorversion" value="${major}" />  
      <capability name="minorversion" value="${minor}" />  
      <capability name="version" value="${version}" />  
      <capability name="w3cdomversion" value="1.0" />  
      <capability name="xml" value="true" />  
      <capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />  
    </capabilities>  
  </browser>  
</browsers>
If adding the above file is still causing a problem, this will be related to that ASP.NET doesn't pick up newly added .browser files if the App_Browsers folder already contain at least one such file, even after the restarting IIS.

The workaround for this:
  1. Add the "w3cvalidator.browser" file to the App_Browsers directory.
  2. Move all the files from the App_Browsers.
  3. Request any site page so that ASP.NET application will be started(with the empty App_Browsers).
  4. Return all the moved files back to the App_Browsers directory.
  5. Try to validate the page via the W3C validator.

Wednesday 10 June 2009

Turn on IIS 6 Compression for CSS and Javascript

  1. Enable HTTP Compression
    1. Open IIS Manager
    2. Right-click "Web Site" and select "Services" tab.
    3. Check "Compress Static Files"
    4. Click "Okay"

  2. Specify that "js" and "css" file should be compressed by changing the metabase. By default, IIS 6.0 is set up to compress htm, html, and txt files.
    1. Open a command prompt
    2. cd to C:\Inetpub\AdminScripts (assuming the default location)
    3. run this command (you can change the list of extensions, but only specify static, compressible files here):
      cscript.exe adsutil.vbs set w3svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "js" "css"

  3. Restart the World Wide Web Publishing Service

Monday 8 June 2009

Add an image to an a tag with no underline

I had a task to add the media mime type icon to a list of document links. The problem was the client didn't want to have the icon underlined. The solution I used was taken from StackOverflow:

Updated the CSS to include

.no-underline {
text-decoration:none;
}
.underline {
text-decoration:underline;
}
And generate the link the XHTML as

<a href="#" class="no-underline">
<span class="underline">
Link text
</span>
<img src="/icon url" alt="alt" />
</a>

Wednesday 3 June 2009

Sitecore 6 RSS Module Error

Have you tried using the RSS module in Sitecore 6 only to get the following error when inserting a new RSS feed?
Item "/sitecore/template/Branches/RSS Feed" is not a template.



The solution to this is as follows.

  • Open the Content Editor
  • Select the RSS Feeds node
  • Select Configure / Assign
  • Remove the RSS Feed item
  • Add the RSS Feed from the sitecore/templates/RSS Module

You will also need to delete the Example feed.