Thursday 24 December 2009

Windows 7 and Application Pool Identity Accounts

Creating a new Application Pool in IIS creates a new security identifier (SID), which is a virtal account. The new identity takes the same name as the AppPool, so a new AppPool with the name 'NewAppPool' creates a new security identifier with the name 'NewAppPool'. You can now use this virtual account so secure your files and folders. However, because the identity is a virtual account it will not show up as a user in the Windows User Management Console.

To use the identity to secure your folder, you need to do the following

  1. Open Windows Explorer

  2. Select the file or directory.

  3. Right click the file and select "Properties"

  4. Select the "Security" tab

  5. Click the "Edit" and then "Add" button

  6. Click the "Locations" button and make sure you select your machine.

  7. Enter "IIS AppPool\NewAppPool" in the "Enter the object names to select:" text box.

  8. Click the "Check Names" button and click "OK".
You can now configure the permissions for the "NewAppPool" identity.

A better article on this from learn.iis.net

Monday 21 December 2009

Turn Off UAC in Windows 7

I find the UAC prompts quite annoying in Windows 7. He is how to turn the propmt off:
  1. Go to Start Menu -> Control Panel -> User Accounts and Family Safety -> User Account.

  2. Click on User Account Control settings link.

  3. Slide the slider bar to the lowest value (towards Never Notify)

  4. Click OK

  5. Restart the computer to turn off User Access Control.

Tuesday 15 December 2009

Hide Live Messenger from the Windows 7 Taskbar

I've just installed Windows Live Messenger and it annoyingly sits in the taskbar rather than the system tray like on Vista and XP.

The trick is to tell Live Messenger to run in Vista Compatibility mode.
  1. Ensure Windows Live Messenger is not running.
  2. Go to Start Menu and locate the Windows Live Messenger shortcut.
  3. Right click on the Windows Live Messenger shortcut and select Properties.
  4. Select the Compatibility tab.
  5. Tick the check box for Run this program in compatibility mode for under “Compatibility Mode”, and then select Windows Vista from the drop down list.
  6. Click OK.
  7. Run Windows Live Messenger.

Tuesday 6 October 2009

Visual Studio 2008 SP1 crashes when switch to Design View

When switching to design view for an ascx control, Visual Studio would close without any warning. In the Application event log, is the error:

.NET Runtime version 2.0.50727.4016 - Fatal Execution Engine Error (72336028) (80131506)

With some reading aross similar problems I came across the following command line that seems to solve the problem by deleting the native images of managed assemblies.

The following command needs to be run from the Visual Studio 2008 command prompt.

ngen /delete *

Thursday 3 September 2009

Broken .designer files

Occasionally I somehow manage to break the designer files, which eventually flag up errors like:

The name 'xxxx' does not exist in the current context.

To fix this, delete the .designer file then right click on the aspx or ascx and select 'Convert to Web Application' this will rebuild the designer file and include all the necessary references to controls.

Tuesday 18 August 2009

Sitecore website with such name has already been installed in this computer

If you develop lots of Sitecore sites, you no doubt have to install, un-install and re-install different versions of Sitecore and have probably come across the following error:

Sitecore website with such name has already been installed in this computer

If this is the case, you need to check in the registry at
HKLM\Software\Sitecore

In this folder is a list of all the versions you have installed using the installer (not applicable if you have used the zipped folder structure)
If you are certain that the site has been deleted previously, you can remove the entry here.

Wednesday 29 July 2009

Sending email via the command line

Log on to the server you are sending the mail from, then in a command prompt enter the following
telnet <smtp server> 25
HELO <domain sending from>
MAIL FROM:<email from>
RCPT TO:<email to>
DATA
<message>
.
QUIT

This will enable you to test that the server can send email via the architecture you are using.

Friday 24 July 2009

Switch IIS to 32bit mode

I've just tried installing a 32bit application in to IIS which was running in 64 bit mode. This didn't work, we had to switch IIS to run in 32 bit mode.

IIS to 32 bit mode


To do this, in a command prompt enter the following
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

You will have to reconfigure ASP.NET by using the following command depending on the version of ASP.NET you have installed.

ASP.NET 1.1

%SYSTEMROOT%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i

ASP.NET 2.0

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

IIS to 64 bit mode

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 0

You will have to reconfigure ASP.NET by using the following command depending on the version of ASP.NET you have installed.

ASP.NET 1.1

%SYSTEMROOT%\Microsoft.NET\Framework64\v1.1.4322\aspnet_regiis.exe -i

ASP.NET 2.0

%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i

This Mircosft KB explains more.

Thursday 16 July 2009

Sitecore - ASP Panel default button not firing

When I was converting a rendering to a sublayout in Sitecore, the ASP:Panel default button event was not firing. The problem was the rendering had the caching settings turned on when it was original assinged to an item. For sublayouts, the caching has to be turned off to enable .NET to bind the controls to events.

The technical problem is when the html for a control is cached, it is not going through the .Net rendering engine, and therefore the control will be missing in the hidden __Eventvalidation field.

So ensure Sitecore caching is turned off for the sublayouts.

Monday 13 July 2009

Default password for VMWare Server 2.0 Web Console

After installing VMWare Server 2.0, you load up the Web Console to be prompted with the following screenshot. At no point in the install are you asked to setup any user accounts.


To login to VMWare Server 2.0 Web Console, logon with an administrative account’s user name for Windows or Linux (Administrator or root) and the corresponding password. A password is required, even if the built-in Administrator account does not have password by default.

Wednesday 8 July 2009

Resource not found for the segment 'xxxx'

I've received a "Resource not found for segment 'xxxx'" whilst using Azure.

This error appears to be triggered in the where clause when I am looking by primary key. I have found some resources that say it will throw an error when looking for a primary key that doesn't exist, rather than null.

The current solution is to wrap the query in an exception block:

try  
{  
  var person = from item in Connection.Persons
  where item.ID == id
  select item;  
  return person;
}  
catch( DataServiceQueryException ex )  
{  
  return null;
}  

Thursday 2 July 2009

Multiple controls with the same ID 'RadSpell$DialogOpener$OverImg'

When using the Sitecore Content editor, the following error constantly keeps appearing.

Multiple controls with the same ID 'RadSpell$DialogOpener$OverImg' were found. Trace requires that controls have unique IDs.

This has been acknowledged by Sitecore as a bug. The workaround is to disable trace. This can be done in the web.config

<trace enabled="false" requestLimit="50" pageOutput="false" traceMode="SortByTime" localOnly="true" />

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.

Wednesday 13 May 2009

Autofix DB users

NOTE! The resolution in this post is being deprecated, please use this post for an updated approach.

When you are copying databases across servers, the SQL users will lose their mappings.
Instead of deleting and recreating, you can use the autofix login script. This will try to match up the user on the database with one that is already available on the server.
EXEC sp_change_users_login 'Auto_Fix', 'username', NULL, 'password';
If the user doesn't exist, then the script will create a new user with the supplied password.

Friday 17 April 2009

CheckBoxList - startIndex cannot be larger than length of string

Have you ever created a custom checkboxlist and then recieved the following error when you submit the form if any of the check boxes are selected?

startIndex cannot be larger than length of string.
Parameter name: startIndex
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7492915
System.Web.UI.WebControls.CheckBoxList.LoadPostData(String postDataKey, NameValueCollection postCollection) +60
System.Web.UI.WebControls.CheckBoxList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +346
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743



I have and it took quite some Googling to find a solution. The error is caused by the checkbox name not following the Microsoft.NET convensions, i.e. ctl13$ctl02$
The solution was to update the name to use UniqueID + $ + index on the end.

protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
{
var labelID = UniqueID + "$" + repeatIndex;
writer.Write(string.Format("<input value=\"{1}\" id=\"{0}\" name=\"{0}\" type=\"checkbox\" {2} />",
labelID,
Items[repeatIndex].Value,
Items[repeatIndex].Selected ? " checked=\"checked\"" : ""));
}

Thursday 2 April 2009

Hidden windows?

I use a dual screen display in work, but when I remote in from home I only have one. Sometimes I have left windows open that seem to appear still on a second monitor. To view these hidden windows. Select the window in the task bar and enter:
Alt + Space bar + M
and then use your arrow keys to move the window in to view.

Monday 30 March 2009

TFS: Change computer name

We have just had to update the names pf our PC to align to a new company policy. One of the things that this broke was the mapping of TFS workspaces. A fix for this the following command.

Using the command promt, navigate to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

Now, using the tf.exe tool
tf workspaces /updateComputerName:MyOldComputerName /s:http://TFServer:8080

Tuesday 24 March 2009

MCPD Web Developer

This morning I successfully passed the MCPD exam 70-547. This is a milestone that I have been aimign for for over a year, from when I started studying for the MCTS early last year.

Thursday 19 March 2009

Sitecore Performance

We have noticed some slow performance using Sitecore recently on some of our websites. One of the options discussed on the SDN forum is to disable the performance counters. I've tried this approach and the improvement in performance is noticeable.

So if you are also having performance issue try disabling the performance counters. To disable the performance counters change the following line in the web.config to false:
<setting name="Counters.Enabled" value="true" />

Monday 9 March 2009

Sitecore alias button

I was trying to give a small group of users access to the Alias button, but couldn't find out how to accomplish this, I had given them access to the ribbon, chunk and command but it still wouldn't show up How did I fix this.
  1. Log in to the master database
  2. Under sitecore/system
  3. Unprotect the alias folder
  4. In the security editor, give the required role read, write, create, delete and rename privileges.
  5. Protect the alias folder.

Friday 20 February 2009

Remote Desktop Slowness

After switching to using Windows Server 2008 for my OS, I noticed that RDC connections could be quite slow.
The following URL mentions the problem and gives a solution:
http://blog.tmcnet.com/blog/tom-keating/microsoft/remote-desktop-slow-problem-solved.asp

The solution that I used was to open a command prompt with admin privileges and run the command:
netsh interface tcp set global autotuninglevel=disabled

Thursday 5 February 2009

Castle and IIS7

If you are using Castle and IIS 7 you may receive the following error:

Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '' to the section on your web.config

This error actual means that you haven't add the PerRequestLifestyle to the modules section within system.webServer.

Just add the following in to your web.config


<configuration>
    <system.webServer>
        <modules>
            <add name="PerRequestLifestyle" type="..." />
        </modules>
    </system.webServer>
</configuration>

Sunday 1 February 2009

Microsoft Press Kit - Library not registered

Have you or are you studying for a Microsoft certification? If you and have installed the Press Kit exams on to a Vista PC, when you run the test software you receive the error:

Run-Time Error -2147319779 (8002801d)
Automation Error
Library not registered

Find it frustrating? To solve this issue, you need to register the VideoSoft component library Vsocx6.
You can do this from the command line with the prompt:

regsvr32 c:\Windows\System32\Vsocx6.ocx

Friday 30 January 2009

Custom error pages in IIS

When creating a custom error page, you need to remember to update the feature settings within IIS.
First, set your error page for the correct status code. e.g. 404
Set IIS either to execute a URL or respond with a 302 redirect.
Then on the right hand action bar, click Edit Feature settings and select the option to use the custom error pages. If this is not done, IIS will still use the default error page.

Searching for a wildcard character in SQL

There are occasions when you need to search for the wildcard character within SQL.

The wildcard characters are:

  • % : Any string of zero or more characters.

  • _ : Any single character.

  • [ ] : Any single character within the specified range ([a-f]) or set ([abcdef]).

  • [^] : Any single character not within the specified range ([^a-f]) or set ([^abcdef]).

To search for any of these characters you need to use the ESCAPE clause.

To search for a text value that contains 10-15% you can use:

SELECT c1
FROM mytbl2
WHERE c1 LIKE '%10-15!% off%' ESCAPE '!'

Wednesday 28 January 2009

ASP.NET MVC 1.0 Release Candidate Available

Microsoft have shipped the ASP.NET MVC 1.0 Release Candidate (RC). It's available to download from here. This is hopefully the last release before they ship the final release, which they are hoping to be next month.

The extensive release notes, all 26 pages detail the upgrade process from ASP.NET MVC Beta and includes all the details that have changed.

Wednesday 14 January 2009

Move window to another monitor

I have two monitors and often find the need to move the window to the other monitor. Dragging the window and then maximising is slow and I wished to find a shortcut to this. reSizer is an application that deals with window enhancements, one of these enhancements is the ability to move a window to another monitor using the shortcut key Win + Backspace.

Thursday 8 January 2009

Output literal text from XSLT

A colleague (Neil Pullinger) and my self have both come across the same problem. Getting the PICS tag to show correctly whilst using Sitecore. The example below is wrong, as the quotes have been escaped. <meta http-equiv="PICS-Label" content="(pics-1.1 &quot;http://www.icra.org/pics/vocabularyv03/&quot; I gen true for &quot;http://www.website.com&quot; r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0))" /> The required output is: <meta http-equiv="PICS-Label" content='(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" I gen true for "http://www.website.com" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0))' /> To achive the second option, we had to use
<xsl:text disable-output-escaping="yes">
    <![CDATA[<meta http-equiv="PICS-Label" content=']]>
</xsl:text>
<xsl:value-of select="$picsrating" />
<xsl:text disable-output-escaping="yes">
    <![CDATA[' />]]>
</xsl:text>

Friday 2 January 2009

Blank <title> tags

If you are using ASP.NET and placehoders to render your metadata. You may notice that it will generate an empty <title> tag. This occurs when using XHTML 1.0 Transitional. I often use placeholders to control the content with in the title tag.

To overcome this, you can add the following in the head tag.

<head>
...
<title visible="false" runat="server"></title>
...
</head>

This turns the <title> tag into a server control, and the visible attribute prevents the blank title from rendering to the page.

Thursday 1 January 2009

New Year = New Look

As it's the New Year I have decided to change the look of this blog. Also to note, my New Years resolution is to try and post here more often.

Happy New Year everyone.