June 21, 2011

Referencing Sitefinity 4.1 Themes, CSS From External Pages

Global styling in Sitefinity 4+ is handled by creating and registering a theme, and then applying it using the admin tool to your Sitefinity page templates:


Pretty easy, but what about if you need to reference that style sheet from an external web page that wasn't created within Sitefinity? Or to reference it right from the markup of your page templates/master pages? Looking at the solution the path will be something like:

/App_Data/Sitefinity/WebsiteTemplates/HomePage/App_Themes/Teal/Global/main.css

But we know the ASP.Net App_Data folder has special permissions that will not allow us to directly reference files within it... if we try to use this path to reference the stylesheet, we'll get a 403 error.

Fortunately, after you register a theme, Sitefinity will automatically re-route directly from the /Sitefinity folder at the root of the application into the /Sitefinity folder that exists at /App_Data/Sitefinity... kind of a client-side backdoor into your themes and templates.

So the easy answer to referencing your Sitefinity themes client-side, is just remove the "/App_Data" from the path. You can see this pathing structure if you look at the source code of your Sitefinity pages as well - example:

<link href="/Sitefinity/WebsiteTemplates/HomePage/App_Themes/Teal/global/main.css" type="text/css" rel="stylesheet" />

Share |

June 02, 2011

Sitefinity 4 "ExceptionManager Cannot be Constructed" error

If you're using Sitefinity 4.x and suddenly begin seeing this curious ASP.Net error:

"The type ExceptionManager cannot be constructed. You must configure the container to supply this value."


...this error results when the App_Data folder, and files within, are marked Read Only - if you're using TFS for source control, make sure your App_Data folder has been Checked Out. Your app should then launch normally.

Share |

May 30, 2011

Resolving Sitefinity 4 Search Not Including Content Pages

I recently encountered an issue where, after creating a Sitefinity SearchIndex for NewsItems, Static HTML and all Content, only the NewsItems were being returned - no Content Pages or Static HTML pages appeared in the results. The response I got was to upgrade to Sitefinity 4.1, SP 1, which wasn't the complete answer, but at least the newer admin UI helped to troubleshoot the problem:

(SearchIndex creation screen)


After going through the upgrade process, helpful error messages began to appear when I re-indexed my SearchIndex, indicating errors were being thrown when certain pages were being crawled.

So the problem really was that one particular call, in this case:
SiteMapBase.GetCurrentNode();
was throwing a null reference exception, only during the Sitefinity crawling process, and quietly killing the addition of the Content Pages to the SearchIndex. After resolving the issue, the full site indexed correctly, and searching returned results as expected. There's no feedback when the SearchIndex is successfully reindexed, however, but you'll see the page subtly refresh. (Maybe a good feature for 4.2)

(SearchIndex admin screen)


After going through this process, I found that you could also troubleshoot indexing issues by launching your app in debug mode, going to the admin tool and re-indexing your problem SearchIndex... The Visual Studio debugger will then point out any problem code.

Share |

May 28, 2011

Styling / Formatting Sitefinity 4 controls

One of the big differences between Sitefinity 3.x and 4 is in the way the style and layout of the controls is handled. In the older versions, you had direct access to the .ascx code in either the ControlTemplates folder or the UserControls folder. In 4.x, all Sitefinity widgets have been compiled into .dlls, with each widget exposing a LayoutTemplatePath property, which allows you to specify a path to your own .ascx file if you need to change the layout beyond what is possible via the other widget properties. It's a cleaner way to do it - in the past, upgrades could overwrite revised template code - now your revised layouts are preserved when upgrading.

You can get to the default LayoutTemplates at Design > WidgetTemplates in the Sitefinity admin area. But here's one problem - many controls, like in my case the Login control, don't have any sample layout code exposed. The first thing I tried was to use the LoginControl ascx from Sitefinity 3.7. The first error message you'll get is:

C001: LayoutTemplate does not contain an IEditableTextControl with ID UserName for the username.


You can rename your controls to get through these errors, but you'll eventually hit a brick wall, as you really need the layout code. Fortunately, Grigori at Sitefinity was good enough to send me the actual LayoutTemplate code, which is not exposed anywhere within Sitefinity. Here is the actual Sitefinity 4 LoginControl LayoutTemplate Code. Grigori tells me this will be included in the next release.

Adding this code to your project, and pointing your LoginControl's LayoutTemplatePath to this ascx will allow you to format your login control any way you want:

Default LayoutTemplate appearance:


Login control using custom theme, css:

Share |

October 26, 2010

SSIS Error Code DTS_E_PRIMEOUTPUTFAILED

Recently, while working on a db integration using SSIS, I had encountered a generic error while working with an XML Datasource: Error Code DTS_E_PRIMEOUTPUTFAILED. There are several scenarios that can produce this error, and there also was another message specifying that the offending element was at character 14988 in the XML. The data at that point in the file looked fairly straightforward, which then led me down the path to thinking the file size might be the problem:

<word>with</word>
<word>a</word>
<word>vegetable</word> <- supposedly offending line
<word>white</word>
<word>rice</word>

After whittling down the data for a test, the problem still existed, so the problem wasn't file size either. It ended up just up being bad data... there were several ampersand (&) characters throughout the file.
The error message referencing character 14988 was just a confusing diversion. After scrubbing the data, SSIS was then able to successfully parse the file and use it as a datasource.

Here's a quick reference to characters needing to be escaped within XML, and their associated escape sequences:

Ampersand(&) - &amp;

Greater Than symbol (>) - &gt;

Less Than symbol (>) - &lt;

Double Quote (") - &quot;

Single Quote (') - &apos;

Share |