Friday, October 22, 2010

IIS terminated web server process during debugging - Application poll ping settings in IIS

When debugging a web application from Visual Studio I've started getting the following error when I take too long to step through a process:

"The web server process that was being debugged has been terminated by Internet Information Services (IIS). This can be avoided by configuring Application Pool ping setting in IIS. See help for further details."

Try increasing the "Ping Maximum Response Time (seconds)" or turning off "Ping Enabled" entirely.

See also:

Wednesday, October 6, 2010

Sitecore CMS 6.2 - Accessing parameters in Sublayouts

<Rant>I often seem to have no end of grief when searching for Sitecore documentation straight from Google. It seems most of the useful information is buried in cookbooks and component references which are in PDF format rather than HTML and require a login to the Sitecore Developer Network. I just find it frustrating that they have lots of good documentation but it is difficult to search. I'm almost tempted to bring all their docs down to a public facing web server and letting it get indexed.</Rant>

As a case and point, I wanted an administrator editing the layout details for a content items control to be able to specify a value that would be mapped into a public property on a user control. The Additional Parameters seemed like a good candidate but didn't lead anywhere with the standard Sitecore install.

Turning to Google I found Anders Dreyers post on Accessing parameters in Sublayouts with Sitecore 5.3.1. At least with that version of Sitecore it looked like parameters weren't easily available in a sublayout.

That post did lead me to Sitecore.Web.UI.SublayoutRenderingType, which is referenced in the web.config as the rendering control for sublayouts. Using Reflector on it shows that the parameters collection could be used to automatically set properties using reflection.

After searching through the Presentation Component Reference I went to the Presentation Component Cookbook PDF via a footnote reference and then onto the SublayoutParameterHelper via another footnote.

4.5.3 How to Pass Rendering Parameters to a Control
To pass parameters to a control using the Control Properties dialog:
  • In the Control Properties dialog, enter control properties.
To pass parameters to a control using the rendering properties dialog:
  • In the rendering properties dialog, click the Parameters tab, and then enter named parameters.12
12 To access the parameters passed to a sublayout, see http://trac.sitecore.net/SublayoutParameterHelper.

Googling for SublayoutParameterHelper lead me back to Cascade the Data Source of a Sublayout down to Nested Controls PDF, which seems to explain how to use the SublayoutParameterHelper.

This looks like just what I was after. By inheriting from Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutBase rather than System.Web.UI.UserControl the parameters will be automatically mapped to the corresponding properties in the sublayout if they exist. Just remember to call base.OnInit() if you override it (as per the documentation).

Friday, October 1, 2010

ASP.NET Control.SetRenderMethodDelegate()

I was looking for a way to inject a WebControl as the next sibling of another HtmlControl where they may not be in a control tree yet. The post Adding Rendering with SetRenderMethodDelegate() - aeh, sort of seemed like a possibility but didn't eventuate as certain controls (Panels) would render their outer content before passing off the the rendering delegate.

Thursday, September 30, 2010

Using jQuery with Sitecore and avoiding conflicts with Prototype

When using jQuery with Sitecore you need to take additional steps so that the jQuery $ function doesn't interfere with the Prototype $ function that Sitecore uses for the Sitecore Ribbon.

Example from api.jquery.com

jQuery.noConflict();
(function($) { 
  $(function() {
    // more code using $ as alias to jQuery
  });
})(jQuery);
// other code using $ as an alias to the other library

See Also:

Friday, September 24, 2010

System.Web.MembershipProvider and RoleProvider references not found in unit tests after VS2010 upgrade

After updating a solution from VS2008 to VS2010 the unit tests for our custom web security providers started failing the builds with messages like:

Error    15    The type or namespace name 'MembershipProvider' could not be found (are you missing a using 
directive or an assembly reference?)    D:\Development\[snip].UnitTests\ProviderHelper.cs
Error    16    The type or namespace name 'RoleProvider' could not be found (are you missing a using 
directive or an assembly reference?)    D:\Development\[snip].UnitTests\ProviderHelper.cs
Error    4    The type name 'RoleProvider' could not be found. This type has been forwarded to assembly 
'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 
Consider adding a reference to that assembly.    D:\Development\[snip].UnitTests\ProviderHelper.cs

The last exception here reveals the issue. The project now needs a reference to System.Web.ApplicationServices

Saturday, September 18, 2010

Writing cleaner WebControl HtmlTextWriter output with a fluent interface

Producing HTML output from a ASP.NET WebControl is fairly verbose in terms of the amount of markup required. This isn't ideal for readability or maintenance.

When I find a workable solution I'll post it here. Right now I'm thinking it will be some form of Fluent interface.

See Also:

Wednesday, September 15, 2010

IE8 Trusted sites not displaying PDFs in a popup window with Adobe Reader 9

First, some background on the development environment:

  • Windows Server 2008 - 64 bit
  • Internet Explorer 8.0.6001.18943 (using the 32 bit exe)
  • The website is running under SSL
  • The site has been added to the Trusted sites security zone with Protected Mode off
  • The functionality works fine in Firefox and Chrome.
  • Adobe Reader 9.3.4
  • Internet Explorer add-on: Adobe PDF Link Helper 9.3.3.177

Steps to reproduce:

  • Login to the SSL site
  • Click on the javascript link that opens a new window with the URL to return the PDF.
  • The popup window opens (in my case as a tab) and is marked as being in the trusted sites zone.
  • The page appears to be completely blank with no content or HTML loaded.

Solutions

It appears the issue could be related to IE8 opening the new tab in a separate process and not correctly passing the session cookies in with the new request. See Stack Overflow IE8 losing session cookies in pop-up windows.

Happened again

This definitely appears to be related to the site being in the trusted zone. In another similar case a pop up window would spawn in a new window without the session cookies when triggered from a trusted zone. When the site was taken out of the trusted zone the pop up would open in a new tab with the session cookies.

Trusted Zones and iframes

Update 23/01/2012 - Encountered another variant of this issue when the website trying to open the popup window was in the trusted security zone and an iframe of a parent site. The parent website that contained the iframe wasn't in the trusted website zone and IE was showing mixed zone security messages. When the popup window appeared it was in the trusted zone but had lost the session cookies.