<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Theodor Klostergaard</title><link href="http://world.optimizely.com" /><updated>2009-01-30T09:44:00.0000000Z</updated><id>https://world.optimizely.com/blogs/Theodor-Klostergaard/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>A postrophe a day keeps the doctor busy</title><link href="https://world.optimizely.com/blogs/Theodor-Klostergaard/Dates/2009/1/A-postrophe-a-day-keeps-the-doctor-busy/" /><id>&lt;p&gt;A little while back one of our customers called us to say the FileManager was broken (this was on an EPiServer 4.6 site). They got an exception when trying to open it. &lt;/p&gt;  &lt;p&gt;The exception was an SQL exception.&lt;/p&gt;  &lt;p&gt;It turned out that one of the editors had created a folder called: &amp;quot;DVD&#39;ere&amp;quot;. Ah...&lt;/p&gt;  &lt;p&gt;EPiServer was in a manner of speaking performing an SQL injection attack on itself by not escaping the apostrophe in the folder name. &lt;/p&gt;  &lt;p&gt;So we figured it would be enough to find the entry in the datatable, rename the folder name manually and everything would be fine. But it wasn&#39;t. The name of the folder was somehow still present in the database.&lt;/p&gt;  &lt;p&gt;Luckily there was EPiServer support - even though they couldn&#39;t give us a hotfix, they guided us through which procedures had to be executed in which order. And all was well again. The customer was happy.&lt;/p&gt;  &lt;p&gt;Then another editor created a folder called &amp;quot;CD&#39;ere&amp;quot;...&lt;/p&gt;  &lt;p&gt;So we took all the statements and wrapped them in a nice tight bundle and now when an editor decides it&#39;s time use an apostrophe, we can run this script exchanging the foldername. To be perfectly on the safe side, you could argue that it should be wrapped in a transaction, but we never got around to that...&lt;/p&gt;  &lt;p&gt;Use at own risk and remember to backup your database first. It has been used for folders that are &lt;u&gt;created&lt;/u&gt; with an apostrophe. We haven&#39;t used it for the day when somebody decides to &lt;u&gt;rename&lt;/u&gt; an existing folder containing folders and files. But then you have EPiServer support :-)&lt;/p&gt;  &lt;p&gt;NB: Later again we edited the EPiServer files that are used for creating and renaming files and folders, so it warns and halts when an apopstrophe is in the name - if you do that you won&#39;t need this script at all :-7&lt;/p&gt;  &lt;p&gt;DECLARE @folderID uniqueidentifier;    &lt;br /&gt;DECLARE @parentID uniqueidentifier;     &lt;br /&gt;DECLARE @folderName varchar(200); &lt;/p&gt;  &lt;p&gt;SET @folderName = &#39;insert_your_foldername_here&#39; -- &#39;DVD&#39;&#39;ere&#39;    &lt;br /&gt;SELECT&amp;#160;&amp;#160;&amp;#160;&amp;#160; @folderID = pkID     &lt;br /&gt;FROM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; tblItem     &lt;br /&gt;WHERE&amp;#160;&amp;#160;&amp;#160;&amp;#160; (Name LIKE @folderName); &lt;/p&gt;  &lt;p&gt;IF (@folderID IS NULL)    &lt;br /&gt;BEGIN     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SELECT &#39;Could not find the folder: &amp;quot;&#39; + @folderName + &#39;&amp;quot;&#39;;     &lt;br /&gt;END     &lt;br /&gt;ELSE     &lt;br /&gt;BEGIN     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SELECT @parentID = FromId FROM tblRelation WHERE toID=@folderID     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; CREATE TABLE #relationTable (toID uniqueidentifier);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; INSERT INTO #relationTable EXEC RelationListFrom @FromId=@folderID,@SchemaId=0;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DECLARE @numberOfRelations int;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SELECT @numberOfRelations = COUNT(*) FROM #relationTable;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DROP TABLE #relationTable;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; IF (@numberOfRelations = 0)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; BEGIN     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXEC RelationRemove @FromId=@parentID,@ToId=@folderID&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXEC ItemDelete @Id=@folderID     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT &#39;Item deleted&#39;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; END     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ELSE     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT &#39;Did not delete&#39;;     &lt;br /&gt;END &lt;/p&gt;</id><updated>2009-01-30T09:44:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Not friendly to all urls</title><link href="https://world.optimizely.com/blogs/Theodor-Klostergaard/Dates/2008/6/Not-friendly-to-all-urls/" /><id>&lt;p&gt;We recently created a site on the EPiServer CMS 5 platform. After having set up the site we started developing, but soon we realized that urls were not being treated as friendly as we might have hoped for. When a friendly url was pasted into the browser directly the appropriate page was shown. But no urls were rendered in a friendly way; they were all rendered as links to the aspx-page with a pageid as parameter.&lt;/p&gt;
&lt;p&gt;First thing we did was to check and recheck the steps necessary to configure EPiServer to use the FriendlyUrlRewriteProvider. It was all good and proper: The urlRewrite element was there and the UrlRewriteModule as well. We tried using the NullUrlRewriteProvider (yes, it did use the rewriteprovider stated as default in the web.config) and switching back to the FriendlyUrlRewriteProvider (maybe it wasn&#39;t paying attention the first time?) but to no avail.&lt;/p&gt;
&lt;p&gt;Reflector to the rescue. [cue Batman theme] How did FriendlyUrlRewriteProvider actually detect which urls to be friendly to?&lt;/p&gt;
&lt;p&gt;After some scrutinizing the following lines awoke our suspicion:&lt;/p&gt;
&lt;p&gt;if (HttpRequestSupport.IsSystemDirectory(url.Path))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return flag;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;What exactly is a SystemDirectory, you may ask? That&#39;s what we asked, anyway.&lt;/p&gt;
&lt;p&gt;It turned out that we had misunderstood what was the true meaning behind the innocently looking uiUrl-attribute in the siteSettings element for the site. A SystemDirectory is a directory that starts with the value of either uiUrl or utilUrl. We had placed our templates under the uiUrl, so every time an url was encountered the FriendlyUrlRewriteProvider figured it was a SystemDirectory and did not bother to rewrite.&lt;/p&gt;
&lt;p&gt;Moving the templates outside the uiUrl and updating the pagetypes appropriately solved the problem.&lt;/p&gt;
&lt;p&gt;While at it we also solved a problem when rewriting urls that contained Danish characters among the parameters, but I&#39;ll post more about that some other time.&lt;/p&gt;</id><updated>2008-06-09T13:28:00.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>