Episerver Importers

  • Page Owner: Not Set
  • Last Reviewed: 2020-03-23

Importing into episerver is a dangerous task and can lead to a lot of back and forth. I'm looking for code examples of files we've imported from and what to. Not APIs.

  • CSV
  • Excel
  • Text
  • Others?

Additional Posts

Here is what I wrote for QRC:

https://gitlab.blendinteractive.com/hsag/quality-reporting-center/blob/master/Projects/QualityReportingCenter.MainSite/Controllers/LookupData/LookupDataAdminController.cs

Probably not the bet way to do it.

/shrug

I wrote a relatively involved importer for importing forum data here: https://gitlab.blendinteractive.com/abs/abs-site/tree/master/ABS/Business/ForumImport

It imports posts and attachments to those posts.

In general, though, there are a few things you'll want to consider when writing a content importer:

  1. Consider making the process interruptible. Some of these processes have to run for hours, and writing your code so it can stop and pickup where it left off may save you a ton of headache in the long rung. At the very least, if you run the import twice, it should update existing pages, rather than create duplicate pages.
  2. In general, it's a good idea to have some kind of reference from the newly imported content to the old content. This might be a "imported URL" property, or "Old ID" if you have an identifier. These things don't seem necessary, until they are. You can make it invisible to editors so you don't confuse anyone.
  3. Think about how you're going to handle linking to content. If the content you're importing references other content you're importing, you'll need a step that updates the links to the new structure, using Episerver internal links so they behave correctly.
  4. Think about how you're importing media. Do you import it to "For this Page," or "For this Site," or "For all Sites"? If you import to "For this Page", then reference that media from another page, you can cause some pretty strange behavior in Episerver. Keep a table of imported media so you're not importing the same dancing baby gif twenty times, but rather recognize that you've already uploaded that item and link to the existing one.
  5. Finally, how are you cleaning the imported HTML? This can be harder than you'd think. I'd recommend whitelisting tags/attributes, rather than trying to blacklist bad stuff. For a heavily over-engineered example, see the ABS Folio import cleanup code: https://gitlab.blendinteractive.com/abs/abs-site/blob/master/ABS/Business/Content/HtmlCleaner.cs#L807. I wouldn't recommend using this code as-is, but it can give you ideas on how to clean up HTML.