public ActionResult ImportToolWidget()
 {
   var m = Session["BlogMLModel"] as BlogMLModel;
   if (m == null) m = new BlogMLModel();
   return PartialView("BlogMLImportToolWidget", m);
 }
    public ActionResult Import(BlogMLModel m)
    {
      //validate input
      try
      {
        HttpPostedFileBase blogml = null;
        if (blogml == null && Request.Files.Count > 0) blogml = Request.Files[0];
        var coll = AppService.GetCollection(new Uri(m.EntryCollectionId));
        if (string.IsNullOrEmpty(m.PagesCollectionId)) m.PagesCollectionId = null;
        if (string.IsNullOrEmpty(m.MediaCollectionId)) m.MediaCollectionId = null;
        if (string.IsNullOrEmpty(m.ImportMode)) m.ImportMode = "Merge";
        if (blogml == null || blogml.ContentLength < 10) throw new Exception("Please post a valid BlogML file.");

        BlogMLBlog blog = null;
        using (XmlReader r = new XmlTextReader(blogml.InputStream))
        {
          blog = BlogMLSerializer.Deserialize(r);
        }

        AdminProgressModel model = new AdminProgressModel() { ProcessName = "BlogML Import" };
        model.Messages.Add("BlogML file parsed successfully");

        //launch a new thread
        new Thread(() => BlogMLService.Import(m.EntryCollectionId, m.PagesCollectionId, m.MediaCollectionId,
          (ImportMode)Enum.Parse(typeof(ImportMode), m.ImportMode), blog)) { IsBackground = true }.Start();
        //ThreadPool.QueueUserWorkItem((s) => Import(s), state);

        model.ProgressUrl = Url.Action("ImportProgress");
        TempData["BlogML-AdminProgressModel"] = m;
        return RedirectToAction("ImportResult");
      }
      catch (Exception ex)
      {
        LogService.Error(ex);
        TempData["error"] = ex.Message;
        Session["BlogMLModel"] = m;
        return RedirectToAction("Tools", "Admin");
      }
    }