After upgrading EPiServer CMS5 r2 to CMS5 r2sp2 you might get a nice little error in edit mode. This page is not available for the active language. This is due globalization changes and the workaround is to activate a language for your site. To do this do the following:

1. Go to admin mode
2. Click on Config
3. Go to systemsettings
4. Activate Globalization
5. Go to Edit mode
6. click on Language Settings
7. Chose the default language
8. Go back to admin mode
9. Turn off globalization

This should do the trick. Remeber, if you have several sites, you need to click on the root of each one of them and set the language settings on all of them.

Using EPiServers softlink can really come in handy in different situations.  Mostly of course when you need to gather information from the linked pages of a document.

Here’s an example on how to use this:

Example in VB.Net

[sourcecode language=’vb.net’]

Dim f As EPiServer.Web.Hosting.UnifiedFile = TryCast(System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(filename), EPiServer.Web.Hosting.UnifiedFile)

Dim filecollection As EPiServer.DataAbstraction.SoftLinkCollection = EPiServer.DataAbstraction.SoftLink.Load(f)

For Each file As EPiServer.DataAbstraction.SoftLink In filecollection
Dim ref As New PageReference
ref = file.OwnerPageLink
’now you can work your magic
Next

[/sourcecode]

Example in C#:

[sourcecode language=’c#’]

EPiServer.Web.Hosting.UnifiedFile f = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(filename) as EPiServer.Web.Hosting.UnifiedFile;

EPiServer.DataAbstraction.SoftLinkCollection filecollection = EPiServer.DataAbstraction.SoftLink.Load(f);

foreach (EPiServer.DataAbstraction.SoftLink file in filecollection) {
PageReference ref = new PageReference();
ref = file.OwnerPageLink;
//now you can work your magic
}

[/sourcecode]

So what you need to do is pretty much to load up the file reference into a softlink and fill a softlinkcollection with that. Then just run a for each on the collection (since a document can have several linking pages). Once you get your reference, you can just do a getpage on the ref and grab whatever you need from the linking page.

One of our customers have a lot of PDF that are linked to their site. Some of these PDF files have % in the filename and this causes a HTTP 400 Bad Request and yes they are encoded correctly. The same error happened with other characters such &, * and :

Finally, the solution was found @ dirk.net with an article regarding 400 bad request in IIS7 (But IIS6 also has the same problem and the solution will work there too). You can read about it here.

I’ve a table where I need to select the posts with the latest date. Problem is that when you get the latest date it also gets it by the hour, meaning that it will try to fetch everything older or equal to the date + time, which is nothing. There for, I need to make it a shortdate so I can fetch everything that was posted on that day.

The following code will set the variabel to the latest date on the table.
[sourcecode language=’sql’]
DECLARE @latestDate as datetime
SET @latestDate = (SELECT postDate from table where postDate = (Select max(postDate) from table))
[/sourcecode]
This will return Jan 20 2009 6:45PM

Then all I need to add to my SELECT is
[sourcecode language=’sql’]
CONVERT(VARCHAR(10), @latestDate, 101)
[/sourcecode]
This will return 01/20/2009

This error happens after a migration to EPiServer CMS 5 r2 when you try to change the password of a user or possibly create a user. The error is very missleading and has nothing to do at all with the role nor membershipprovider. The error is actually a very simple one.

Another user is using the email that you are providing or your user does not have an email at the moment.

All you need to do is either delete one of the users or change the mail adress of one of the users in order to ”lock them up” and be able to change the password.

An ex colleague of mine has started up a blog regarding flashdeveloping in AS3. Robert is a very talented flash developer with a huge portfolio on his back. If you fancy Flash developing, then head over to his blog and bookmark it. The link can also be found on the right column of the page

During a makeover of a site I ran into a great site which puts up what that  has been removed from strict xhtml and also a very good overview of all elements and attributes for different doctypes. You can search or browse all elements and see which attributes that are allowed which is of great help when you’re cleaning up a site that uses old attributes. Great example is ”accesskey” which is still allowed in href, labels and a few more, but not in header elements and so forth. Go over there and make sure to bookmark it!

*edit* Thanks Jonatan, what a misstake I made 🙂 the links are now correct

So during an upgrade to EPiServer 5, I ran into this problem where the culture was wrong and all translations were being translated to English instead of Swedish, this even though the web.config was correctly changed to ”sv-SE”.

After som trial and error I got to set the culture in onpreinit in the a class that inherits templatepage like this

EPiServer.Globalization.UserInterfaceLanguage.Instance.SetCulture(”sv-SE”)
EPiServer.Globalization.SystemLanguage.Instance.SetCulture(”sv-SE”)

The problem was that only the dates were being formatted correctly, but the translation was still wrong. CurrentPage.LanguageID was not of much help either as it was set to english. At last I found out that you just need to send the short version of the culture to make it work. i.e

EPiServer.Globalization.UserInterfaceLanguage.Instance.SetCulture(”SV”)
EPiServer.Globalization.SystemLanguage.Instance.SetCulture(”SV”)

This did the trick and now everything is in the right format.

It’s comfortable to just use properties directly in the page. i.e
[sourcecode language=’html’]

[/sourcecode]
Problem with this, is that it will render an extra div which feels really unnecessary. I’ve tried to look around for a setting of some sort to turn this off but not wanting to waste too much of my time, I just did a simple workaround. Well I didn’t do a workaround, I just render my text in another way.

Front:
[sourcecode language=’html’]

[/sourcecode]
Back:
[sourcecode language=’vb’]
txtMainBody.Text = CurrentPage.Property(”MainBody”);
[/sourcecode]
This will render out exactly whats in MainBody and nothing extra.
Remember to check for nulls 😉