Using VistaDB Express as your BlogEngine.NET back end

VDBLOGO-Small It is a day later than I had hoped, but I now have my blog running with a VistaDB back end.  I'm thrilled. I've never been a huge fan of putting my personal blog data in SQL Server and I feel free.

I had never intended to move my data to VistaDB Express when I started work for this presentation a few weeks ago, but after working with it for a while and making the providers, I realized I really wanted to use it for my data storage.  VistaDB has a lot going for it as it is managed code, runs in medium trust, runs on mono and is very lightweight.  I'm really most pleased with the xcopy deployment and the nice graphical management tool.  I have heard from others that speed might be an issue, but it seems fine with the small tests I've run.  Inside BlogEngine with the caching we do, I don't see it as an issue.

As I was making some small changes to the code to make it more secure and getting it ready to make available, I decided to go for it.  I fired up my rough migration tool, made a few small changes, and I had a complete copy of my blog posts, pages, comments, settings, and other stuff in a VistaDB database.  I had to manually add my user name in, but since I'm single user it was no big deal.  My small blog database is less than 1 MB and even easier to copy around than a few directories full of XML files.

If you are interested in playing around with it, or following in my footsteps to using VistaDB Express for your blog data, I'm making it all available now.  Complete with instructions.  If you wish to use it, you are required to meet the license agreement of VistaDB Express which states that it is for non-commercial use.  (If you are a commercial operation, you can purchase VistaDB and then use it with BlogEngine without restriction.)

  • Download this file: BlogEngine131VistaDB33.zip
  • Unzip the file and place the 2 dll files in your blog's bin folder.  (Note: one is the VistaDB Express dll and one is the BlogEngine VistaDB providers.)
  • Place the BlogEngine.* files in your blog's App_Data folder.  These 2 files are your initial VistaDB database.
  • Make changes to your web.config to let BlogEngine know to use VistaDB.  I've included samples of the relevant areas below.
  • As per the VistaDB Express license, you should place a link back to VistaDB somewhere on your blog.  (I placed mine in my footer.)

 

Near the top of your web.config


<BlogEngine>

    <blogProvider defaultProvider="VistaDBBlogProvider">

      <providers>

        <add name="XmlBlogProvider"

             type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>

        <add name="MSSQLBlogProvider"

             type="BlogEngine.Core.Providers.MSSQLBlogProvider, BlogEngine.Core"/>

        <add name="VistaDBBlogProvider"

             type="BlogEngine.Core.Providers.VistaDBBlogProvider, BlogEngine.VistaDB"

             dataSource="~/App_Data/BlogEngine.vdb3"

             password="" />

      </providers>

    </blogProvider>

</BlogEngine>


Down under system.web


 <membership defaultProvider="VistaDBMembershipProvider" >

   <providers>

     <clear />

     <add name="XmlMembershipProvider"

          type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core"

          description="XML membership provider"

          xmlFileName="~/App_Data/users.xml"/>

     <add name="VistaDBMembershipProvider"

          type="BlogEngine.Core.Providers.VistaDBMembershipProvider, BlogEngine.VistaDB"

          dataSource="~/App_Data/BlogEngine.vdb3"

          password="" />

   </providers>

 </membership>



 <roleManager defaultProvider="VistaDBRoleProvider"

              enabled="true"

              cacheRolesInCookie="true"

              cookieName=".BLOGENGINEROLES">

   <providers>

     <clear />

     <add name="XmlRoleProvider"

          type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core"

          description="XML role provider"

          xmlFileName="~/App_Data/roles.xml"/>

     <add name="VistaDBRoleProvider"

          type="BlogEngine.Core.Providers.VistaDBRoleProvider, BlogEngine.VistaDB"

          dataSource="~/App_Data/BlogEngine.vdb3"

          password="" />

   </providers>

 </roleManager>

 

That is it.  If you are interested in checking out the VistaDB database or want to encrypt the database with a password, you can download VistaDB Express.  (User passwords are encrypted inside the database in the User table, but you can encrypt the whole file if you'd like.)  The initial database has the default settings and the initial welcome post you come to expect.

Comments

5/25/2008 10:34:59 PM #

Nigel

Very interesting looking forward to trying it out. I presume that it will be necessary to remove all the xml data etc from the web.config.

Nigel United States |

5/25/2008 11:52:01 PM #

Al Nyveldt

Not all.  You can leave your xml and SQL providers listed and just add the VistaDB config info.  The key is setting the default providers.  Set the default to the one you want BlogEngine to use.

Al Nyveldt United States |

5/31/2008 11:44:02 AM #

Rahul Goel

I am facing one problem with the setup of BlogEngine with Vista DB

I am not able to log in.

Can you help me?

Rahul Goel India |

6/1/2008 7:47:47 AM #

Al Nyveldt

When you switch over, you are also moving your membership and roles data which is your login info.  So immediately after the switch, you'll be back to logging in with username: Admin and Password: admin.  You should be able to log in with those and then add your username back in and delete or update the admin user.  If you are having problems, with that user and password, double check your membership and roles configuration in the web.config.

Al Nyveldt United States |

6/2/2008 4:38:07 AM #

Rahul Goel

I tried the same way and I cross checked the web.config file, but still the same problem is there, Please do help me

<?xml version="1.0"?>
<configuration>

  <configSections>
    <sectionGroup name="BlogEngine">
      <section name="blogProvider" requirePermission="false" type="BlogEngine.Core.Providers.BlogProviderSection, BlogEngine.Core" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
    </sectionGroup>
  </configSections>

  <BlogEngine>
    <blogProvider defaultProvider="VistaDBBlogProvider">
      <providers>
        <add name="XmlBlogProvider"
             type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
        <add name="MSSQLBlogProvider"
             type="BlogEngine.Core.Providers.MSSQLBlogProvider, BlogEngine.Core"/>
        <add name="VistaDBBlogProvider"
             type="BlogEngine.Core.Providers.VistaDBBlogProvider, BlogEngine.VistaDB"
             dataSource="~/App_Data/BlogEngine.vdb3"
             password="" />
      </providers>
    </blogProvider>
</BlogEngine>



  <!-- configSource is not implemented in Mono.
    <connectionStrings configSource="sql.config" />
  -->

  <connectionStrings>
    <clear/>
    <add name="LocalSqlServer" connectionString="dummy"/> <!-- Mono complains if LocalSqlServer isn't specified -->
    <add name="BlogEngine" connectionString="Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogEngine;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

  <appSettings>
    <add key="BlogEngine.FileExtension" value=".aspx" />
    <!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
    <add key="BlogEngine.VirtualPath" value="~/" />
    <!-- The regex used to identify mobile devices so a different theme can be shown -->
    <add key="BlogEngine.MobileDevices" value="(nokia|sonyericsson|blackberry|samsung|sec-|windows ce|motorola|mot-|up.b)" />
  </appSettings>

  <system.web>
    
    <compilation debug="true" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto" />
    <httpRuntime enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="16384" executionTimeout="3600" requestLengthDiskThreshold="16384" />
    <trust level="High" />

    <machineKey
      validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C"
      decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4"
      validation="SHA1" decryption="AES"
    />

    <authentication mode="Forms">
      <forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies" />
    </authentication>

    <pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
      <controls>
        <add namespace="Controls" tagPrefix="blog"/>
      </controls>
    </pages>

    <customErrors mode="RemoteOnly">
      <error statusCode="404" redirect="~/error404.aspx" />
    </customErrors>

    <membership defaultProvider="VistaDBMembershipProvider" >
   <providers>
     <clear />
     <add name="XmlMembershipProvider"
          type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core"
          description="XML membership provider"
          xmlFileName="~/App_Data/users.xml"/>
     <add name="VistaDBMembershipProvider"
          type="BlogEngine.Core.Providers.VistaDBMembershipProvider, BlogEngine.VistaDB"
          dataSource="~/App_Data/BlogEngine.vdb3"
          password="" />
   </providers>
</membership>

<roleManager defaultProvider="VistaDBRoleProvider"
              enabled="true"
              cacheRolesInCookie="true"
              cookieName=".BLOGENGINEROLES">
   <providers>
     <clear />
     <add name="XmlRoleProvider"
          type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core"
          description="XML role provider"
          xmlFileName="~/App_Data/roles.xml"/>
     <add name="VistaDBRoleProvider"
          type="BlogEngine.Core.Providers.VistaDBRoleProvider, BlogEngine.VistaDB"
          dataSource="~/App_Data/BlogEngine.vdb3"
          password="" />
   </providers>
</roleManager>


    <siteMap defaultProvider="PageSiteMap" enabled="true" >
      <providers>
        <add name="PageSiteMap" description="The site map provider that reads in the .sitemap XML files." type="BlogEngine.Core.Web.Controls.PageSiteMap, BlogEngine.Core"/>
        <add name="SecuritySiteMap" description="Used for authenticated users." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" securityTrimmingEnabled="true" siteMapFile="Web.sitemap" />
      </providers>
    </siteMap>
    
    <httpModules>
      <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
      <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
      <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
      <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
      <!--The CleanPageModule below removes whitespace which makes the page load faster in IE. Enable at own risk -->
      <!--<add name="CleanPageModule" type="BlogEngine.Core.Web.HttpModules.CleanPageModule, BlogEngine.Core"/>-->
      
      <!--Remove the default ASP.NET modules we don't need-->
      <remove name="PassportAuthentication" />
      <remove name="Profile" />
      <remove name="AnonymousIdentification" />
    </httpModules>

    <httpHandlers>
      <add verb="*" path="file.axd" type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="syndication.axd" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" validate="false"/>
      <add verb="*" path="trackback.axd" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="pingback.axd" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="opensearch.axd" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="metaweblog.axd" type="BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="monster.axd" type="BlogEngine.Core.Web.HttpHandlers.MonsterHandler, BlogEngine.Core" validate="false"/>
      <add verb="*" path="blogml.axd" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler, BlogEngine.Core" validate="false"/>
    </httpHandlers>

  </system.web>
</configuration>

Rahul Goel India |

6/4/2008 4:11:36 PM #

fruzicka

Take a look in the .vdb3 file ... default user has name: VistaDB and password: admin, so change this first.

Also add following to your web.config <configuration> section:

  <system.data>
    <DbProviderFactories>
      <remove invariant="VistaDB.NET20"/>
      <add name="VistaDB.Provider" invariant="VistaDB.NET20" description=".Net Framework Data Provider for VistaDB" type="VistaDB.Provider.VistaDBProviderFactory, VistaDB.NET20, Version=3.3.1.57, Culture=neutral, PublicKeyToken=DFC935AFE2125461"/>
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="VistaDB.NET20" publicKeyToken="DFC935AFE2125461" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-3.3.1.56" newVersion="3.3.1.57"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

... then it should work.

fruzicka Austria |

6/11/2008 11:18:58 AM #

shah

i've made sure everything is according to the tutorial by Al but still cannot log in. There is a username = VistaDB with password: admin. But when i try to login, "Invalid username" error message appears. I even tried fruzicka's suggestion above but no joy. What else can I do?

shah Malaysia |

6/11/2008 7:02:10 PM #

Al Nyveldt

The default username is admin and the default password is admin.

Al Nyveldt United States |

6/12/2008 4:57:02 PM #

shah

still not getting it right.

shah Malaysia |

Comments are closed
Recent Comments