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();
}