A fix for the Blog Engine Importer tool problem...?

by Paul Kohler 24. October 2008 08:03

The problem with the importer is more that it hides the real issue. An exception in the BlogImporter web service is caused when a DateTime.MinValue is mdoified for the timezone - so depending on your timezone you will get the error :)  This throws an unhandled exception resulting in a SOAP error and the blog importer client interprets this as a username/password issue.

IMHO (!) the easiest fix is...

Open up BlogEngine.NET\api\BlogImporter.asmx from the website.

Find the "AddPost" Method, duplicate (what in my build is) line 84 but assign to "post.DateModified = import.PostDate" or "post.DateModified = DateTime.Now". Updating it to the current time is possibly "more correct"... up to you...

Now you should be able to run the importer :-)

The code should look something like this:

    [SoapHeader("AuthenticationHeader")]
    [WebMethod]
    public string AddPost(ImportPost import, string previousUrl, bool removeDuplicate) {
        ...snip...

        Post post = new Post();
        post.Title = import.Title;
        post.Author = import.Author;
        post.DateCreated = import.PostDate;
        post.DateModified = import.PostDate; // or "DateTime.Now"
        post.Content = import.Content;
        post.Description = import.Description;
        post.IsPublished = import.Publish;
        ...snip... 
        post.Import();

        return post.Id.ToString();

    }

 

Comments

11/2/2009 8:09:15 PM #

trackback

How to migrate from dasBlog to BlogEngine.NET!

How to migrate from dasBlog to BlogEngine.NET!

exDream Blog |

2/16/2010 12:09:53 AM #

Andrew

Thanks this just helped me out of a bind.

Andrew United States |

About the author

Paul Kohler, .net developer living and working in Brisbane, Australia...

Email me via the contact page or browse to the main PK Software site.