Al Nyveldt

Adventures in Code and Other Stories

Earlier today, the BlogEngine.NET team published the latest version of BlogEngine.NET, version 1.4.5.  It is a minor release compared to our previous releases, but an important one.

benlogo80 BlogEngine.NET 1.4 came out only a month ago, but we have a few fixes we wanted to get out to the world as soon as we could to make BlogEngine life better for everyone.  We have a few bugs that were hindering new people getting started as well as medium trust issues at certain hosting providers.  In addition, there are a bunch of other bug fixes in this release along with a few goodies to entice you to upgrade even if you are happily working along in 1.4.0.

The latest version has put all the database support I’ve been making available here right in the download now, so you can quickly and easily get your instructions and scripts for SQL Server, MySQL, SQLite, and VistaDB.  In the case of VistaDB and SQLite, we actually have initial database files to start with instead of installation scripts.  All upgrade scripts are included in the setup folder as well.

We have added more features into our Metaweblog API support.  We now support choosing the author by drop down if you are connected as an administrator.  The Live Writer dropdown list will show you all available users you may post for.  In addition, we have also made it easy to enforce SSL for your Metaweblog connection.  If you have it, you may as well, take advantage of it.

There is some cool new APML features along with a few other things to make your blog experience better.  Between the fixes, performance improvements, and new features, you can’t go wrong.

I’ll be working up an upgrade guide and should have it posted in the next 24 hours.

You can download the new version here.

An interesting thread is going around asking how you got started in Software Development.  It seems fun and since Mads tagged me, I thought I’d fess up as well.

How old were you when you started programming?

I guess I started programming when I was about 12 or 13 on my Commodore 64.  It was nothing too wild.  My big project was something I did for the science fair at school.  I had played around with Apple graphics stuff prior to my Commodore, but never got much beyond some simple graphics stuff (and Ultima II) with them.

How did you get started in programming?

I was always interested in computers growing up and after much begging, my parent’s got me a Commodore 64 for Christmas one year.  I played tons of games on that thing, but I did begin to get interested in making them do more.  When I had the chance to actually learn some programming in High School, I knew I’d like it.  So the Commodore 64 sparked the interest, and 2 high school classes got me started doing much more than the very basics.

What was your first language?

My first language was Basic.

What was the first real program you wrote?

Real?  I guess that science fair project was real as I didn’t fail science.  It had something to do with the periodic table, but I can’t really remember. 

What languages have you used since?

Pascal, Fortran, Lisp, Cobol, C, C++, Assembly, FoxPro, FilePro, Visual Basic, ASP, C#, ASP.NET, JavaScript and probably a few others I’ve missed.

What was your first professional programming gig?

My first programming job was with a real estate appraisal firm.  I got a lot of experience there doing everything from setting up Unix servers, to managing GIS projects, to programming.  It was a very interesting job and I stayed there for almost 5 years.

If you knew then what you know now, would you have started programming?

Probably.  I still find software development challenge and rewarding. 

However, I was highly skilled in kicking a soccer ball as a freshman in high school.  I was terrible at soccer, but I could shoot hard and place the ball well.  If I knew that kicking field goals might make for a nice living, I might have worked in that direction a bit.  With a bit of luck (ok, ok, a ton of luck), I’d be about to head off to training camp for my 15th NFL season with the San Diego Chargers.  If that had not worked out, I’d probably fall back on Software Development.

What is the one thing you would tell new developers?

Read other peoples code and let them read yours.

Reading code is an obvious statement as everyone has searched for a code sample of something or other.  However, reading beyond a short snippit to see a larger picture and to learn new ways to do things, not just specific functions.  There is just something about a reading through a well thought out project to see how the developers made it work.

Also, don’t be afraid to show others your code.  Ideally, you can check out ego at the door while you show your code to the other developers.  While you might not like the feedback you get all the time, you will often learn new ways of looking at something as well as better ways to do things.

Its all about continual improvement!

What’s the most fun you’ve ever had … programming?

Probably building my first web site.  I made a web store, GameSurplus.com back in 2000.  It may have been the ugliest web store to ever exist, but I had fun building it and running it.  (The new owners gave it a face lift.) 

I didn’t really planned on actually building a full web store.  At first, I just bought a bunch of games to sell on eBay.  Then I thought I’d make a static one page site, listing what games I had for sale so people could buy them direct and I could avoid the eBay fees.  It just keep growing and growing and I never really planned it all out.  Next, I added a database to update the games and stock.  Shortly afterward, a shopping cart and PayPal checkout were added.  It went on and on.  (Credit cards, Shipping calculators, tracking numbers, pre-orders, internal inventory reports, etc.)

It was fun as I never knew what it was going to need next and often my wife would work with me helping me to see the best way for the site or admin features to work.  My favorite feature was setting it up to automatically print out all the orders as they came in.  It was always fun to come home for the day and see a nice stack of orders on the printer.

Outgoing?

I guess I get to tag some others, so a few of the people who I’d be interested in hearing from would be Ruslan Tur, Steve Eichert, and Steve Harman.

SQLite After a few requests, I decided to go back and do another data provider for BlogEngine.NET.  This time around I’m using SQLite.  SQLite is a file based format very similar to VistaDB Express and it has no restrictions .  It is another fine option for blog data and very easy to work with.

Once again, this is a complete provider setup.  It will store all your blog posts, pages, profiles, users, roles, and settings.  It could be partially implemented by making changes to the default providers in your web.config if you desire.

The process for getting setup is very easy.  The instructions are assuming you have BlogEngine.NET setup already.  If you don’t please check out the initial setup screen cast to walk you through the process.  If you already have an existing blog, be sure to backup before following these steps.

1. Download the SQLite database provider for BlogEngine and unzip it.

2. Download the SQLite ADO.NET Provider binaries.

3. In your SQLite ADO.NET download, find the System.Data.SQLite.DLL and add it to your blog’s bin folder.

4. From the BlogEngine download, copy the BlogEngine.s3db file to your blog’s App_Data folder.

5. Next, replace your blog’s web.config file with the new web.config file from the BlogEngine download.

6. Browse out to your blog and you should see the BlogEngine with SQLite welcome post. 

7. Your User security has been reset, so login as Admin (with the password, admin), add new users, and change your password.

That is it.  You should be now blogging with data stored in SQLite.

great detective If you are a BlogEngine user who prefers databases, you will see a bunch of new stuff when you download the latest version, 1.4.

For the un-initiated, BlogEngine.NET makes use of the provider model to handle its blog data storage.  By default, BlogEngine uses XML for data storage and the provider implementation is simply called the XMLBlogProvider.  Since version 1.0 however, BlogEngine.NET has allowed for SQL Server to be used as a backend as well.  The provider was called, the MSSQLBlogProvider.  By making some simple changes in your web.config, you could tell BlogEngine to use one method of storage or the other. 

Additionally, BlogEngine.NET has also historically made use of the Membership and Role providers and have used an XML implementation of these.  A user could always add the settings to use the SQL Server membership and roles providers if they wanted to.

In BlogEngine.NET 1.4, the old MSSQLBlogProvider is now gone and in its place there is a shiny new DbBlogProvider.  In addition, as you look down through the web.config, you’ll notice a DbMembershipProvider, DbRoleProvider, and DbProfileProvider.  We’ve also added in the SQLMembershipProvider and SQLRoleProvider to make it easier for people to use these as well if they wish.  None of these new providers are set as the default provider, but they are there and ready to be used by the right person.

DbBlogProvider

The DbBlogProvider is an upgrade for the MSSQLBlogProvider.  There are a few main differences however.  At a basic level, it simply has more calls as the base class, BlogProvider, has more calls and supports more items to be handled by the BlogProvider.  However, beyond the additional calls, it has been changed to work with DbProviderFactories.  Basically, this means that instead of creating connections, commands, and readers using the old familiar SQLConnection, SQLCommand, and SQLDataReader objects, it is now using the DbProviderFactory classes to create these.

A simplified explanation of the DbProviderFactory is that this factory class will be responsible for creating all the needed connections, commands, parameters, and readers.  The class is created using the provider listed in your web.config.

   1: <connectionStrings>
   2:     <clear/>
   3:     <add name="LocalSqlServer" connectionString="dummy"/>
   4:     <!-- Mono complains if LocalSqlServer isn't specified -->
   5:     <add name="BlogEngine" 
   6:          connectionString="Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogEngine;" 
   7:          providerName="System.Data.SqlClient"/>
   8:     <add name="BlogEngineVistaDB" 
   9:          connectionString="Data Source=|DataDirectory|\BlogEngine.vdb3;Open Mode=NonexclusiveReadWrite" 
  10:          providerName="VistaDB.NET20"/>
  11: </connectionStrings>

As you can see above, the providerName property in these connectionString items tell us what type of connection objects will need to be used.  The DbFactoryProvider class created with the appropriate providerName will make all the connection, command, parameter, and reader objects of the desired type.

Ok, now that we have a basic understanding of the DbProviderFactory, let’s look again at the DbBlogProvider.  The DbBlogProvider is configured with a connectionString.  (There are a few other options which I’ve added to the sample below and will discuss briefly later.)

   1: <BlogEngine>
   2:     <blogProvider defaultProvider="DbBlogProvider">
   3:         <providers>
   4:             <add name="XmlBlogProvider" 
   5:                  type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
   6:             <add name="DbBlogProvider" 
   7:                  type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" 
   8:                  connectionStringName="BlogEngine"
   9:                  tablePrefix="be_"
  10:                  parmPrefix="@" />
  11:         </providers>
  12:     </blogProvider>
  13: </BlogEngine>

In the above samples, you can see that DbBlogProvider is set to use the BlogEngine connectionString.  And the sample 1, you could see that the provider for the BlogEngine connectionString is System.Data.SqlClient.  The DbBlogProvider will make a DbProviderFactory that will make SqlClient conection, command, parameter, and data reader objects.

If you look back at the second sample, you’ll notice that the DbBlogProvider shown above has a few other options in it.  These are optional and not required by the DbBlogProvider.  (In truth, the connectionString isn’t required either as it will look for a connectionString named BlogEngine if it isn’t listed.)

The tablePrefix option is fulfilling a request that we have had from a number of users.  By default, the installation scripts will create all the BlogEngine tables that all start with “be_”.  If you want to rename your table and have them have a different or no prefix, you can do that and just tell BlogEngine in the provider options what tablePrefix to use.  If the option is not listed in your web.config, it will default to “be_”.

Secondly, we have a parmPrefix option.  All database calls made in BlogEngine.NET use parameters.  The databases I’m most familiar with use the @ sign on the front of parameters, but different databases use different characters for this.  If you wanted to use, MySql for example, you will want to change this option to use the “?” character as the parmPrefix.  Again, by default, BlogEngine will use the @ character if this option is not listed.

The DbBlogProvider is expecting certain tables and fields for storing data.  You can see the tables and fields by checking out the MSSQLSetup script in the Setup folder of your web site.  (The script works only on Microsoft SQL Server,but you can get an idea of what how the tables need to be set up by looking at it.)

DbMembershipProvider

The DbMembershipProvider is another new class with BlogEngine.NET 1.4.  It is a simple membership provider that uses the same DBProviderFactory setup that DBBlogProvider uses.  This way, you can set up a table in your database of choice and store this information there.  The DbMembershipProvider is not full featured, but works fine within BlogEngine.  Many databases already have Membership providers written for them, but it is nice to just have a simple built in BlogEngine version so you don’t need to worry about more dlls.

   1: <membership defaultProvider="DbMembershipProvider">
   2:     <providers>
   3:         <clear/>
   4:         <add name="DbMembershipProvider" 
   5:              type="BlogEngine.Core.Providers.DbMembershipProvider, BlogEngine.Core" 
   6:              passwordFormat="Hashed" 
   7:              connectionStringName="AlsVistaDB"
   8:              tablePrefix="be_"
   9:              parmPrefix="@" />
  10:     </providers>
  11: </membership>

The membership provider has the same connectionStringName, tablePrefix, and parmPrefix options as the DbBlogProvider.  The only new option is passwordFormat.  This option controls how the passwords are stored.  It can be set to Hashed or Clear.  It will default to Hashed if it is omitted.

The DbMembership Provider is look for a table called be_Users.  Here is the fields it uses:

UserID int
UserName string
Password string
LastLoginTime datetime
EmailAddress string

DbRoleProvider

The DbRoleProvider much like the DbMembershipProvider is a simple RoleProvider.  It is not full featured, but works fine within BlogEngine.  It uses the the same DbProviderFactory setup and the connectionStringName, tabelPrefix, and parmPrefix options.

It uses two tables.  The first is called be_Roles.  It has 2 fields.

RoleID int
Role string

The other table is called, be_UserRoles.  Here are the fields it uses:

UserID int
RoleID int

DbProfileProvider

Lastly, we have the DbProfileProvider.  Again, this is just like the others.  It uses the DbProviderFactory and the same 3 options, connectionStringName, tabelPrefix, and parmPrefix.  It has 1 table it uses called be_Profiles.

UserName string
SettingName string
SettingValue string

Anyway, that should should cover anything and everything you might want to know about these new providers in BlogEngine.NET 1.4.

If you are reading this blog regularly, you are now likely tired of the database themes going on this week.  First, it was SQL Server and BlogEngine.  Then VistaDB Express and BlogEngine.NET complete with download.  Today, I’m moving on to MySql.

Let me start this post by admitting right up front that I have almost zero experience with it.  I didn’t even get it installed until last week and that was just to make sure the BlogEngine.NET could work with it.  So instead of completely embarrassing myself by doing a screencast with something I know nothing about, I figured I’d just write up a guide on how to do get started with BlogEngine and MySql and embarrass myself with text.

Requirements

I’m expecting you have BlogEngine.NET installed with the default settings and providers.  If you need help getting to this point, you should check out my initial installation screencast.

Second, I’m expecting you have a MySql database setup and some administration tool to work with.  If you need help getting to this point, I wish you the very best. :)  Actually, I was truly miserable until Ruslan Tur recommended Toad for an admin tool.  This made my experience much, much better.

Creating a Database

You’ll need to create a database or have a database to put the BlogEngine table in.  I have created a script to get the initial tables and data created for you.  Just execute it against the database you want to use for BlogEngine.NET.  Download the script here.

Add the MySQL dll to your bin folder

You’ll need to download the MySQL Connector/NET 5.1, find the MySql.Data.dll, and added to your bin folder.

Update your web.config

I’m including a sample web.config for you to download, but I’ll go through the changes here. (Download Sample web.config.)

First, we need to let BlogEngine know about this new MySQL dll we just added.  This is done by adding the assembly to the list of assemblies and then adding in the system.data section to let BlogEngine know where it will find the MySQL DBProviderFactory.

   1: <system.data>
   2:     <DbProviderFactories>
   3:         <clear />
   4:         <add name="MySQL Data Provider" 
   5:              invariant="MySql.Data.MySqlClient" 
   6:              description=".Net Framework Data Provider for MySQL"  
   7:              type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=5.1.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   8:     </DbProviderFactories>
   9: </system.data>
  10: <system.web>
  11:     <compilation debug="false">
  12:         <assemblies>
  13:             <add assembly="MySql.Data, Version=5.1.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
  14:             <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  15:             <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  16:             <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  17:             <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  18:             <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  19:             <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  20:             <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  21:         </assemblies>
  22:     </compilation>
  23:     < ....snip..../>
  24: </system.web>

Then, you will need to add your connection string to your connectionString section.

   1: <connectionStrings>
   2:         <clear/>
   3:         <add name="LocalSqlServer" connectionString="dummy"/>
   4:         <!-- Mono complains if LocalSqlServer isn't specified -->
   5:         <add name="BlogEngine" 
   6:              connectionString="Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogEngine;" 
   7:              providerName="System.Data.SqlClient"/>
   8:         <add name="MySQLDB" 
   9:              connectionString="Server=localhost;Database=blogengine;Uid=beUser;Pwd=beUser;" 
  10:              providerName="MySql.Data.MySqlClient"/>
  11:     </connectionStrings>

Lastly, we need to link up the BlogProvider, the MembershipProvider, the RoleProvider, and the ProfileProvider.  The BlogProvider section is near the top of your web.config in a BlogEngine section.  The other 2 can be found in in succession down much further in the file.

   1: <BlogEngine>
   2:     <blogProvider defaultProvider="DbBlogProvider">
   3:         <providers>
   4:             <add name="XmlBlogProvider" 
   5:                  type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
   6:             <add name="DbBlogProvider" 
   7:                  type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" 
   8:                  connectionStringName="MySQLDB" 
   9:                  parmPrefix="?"/>
  10:         </providers>
  11:     </blogProvider>
  12: </BlogEngine>

 

   1: <profile enabled="true" defaultProvider="DbProfileProvider" inherits="BlogEngine.Core.Web.AuthorProfile" automaticSaveEnabled="false">
   2:     <providers>
   3:         <add name="XmlProfileProvider" 
   4:              type="BlogEngine.Core.Providers.XmlProfileProvider, BlogEngine.Core"/>
   5:         <add name="DbProfileProvider" 
   6:              type="BlogEngine.Core.Providers.DbProfileProvider, BlogEngine.Core" 
   7:              connectionStringName="MySQLDB" 
   8:              parmPrefix="?" />
   9:     </providers>
  10: </profile>
  11: <membership defaultProvider="DbMembershipProvider">
  12:     <providers>
  13:         <clear/>
  14:         <add name="XmlMembershipProvider" 
  15:              type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" 
  16:              description="XML membership provider" 
  17:              passwordFormat="Hashed"/>
  18:         <add name="SqlMembershipProvider" 
  19:              type="System.Web.Security.SqlMembershipProvider" 
  20:              connectionStringName="BlogEngine" 
  21:              applicationName="BlogEngine"/>
  22:         <add name="DbMembershipProvider" 
  23:              type="BlogEngine.Core.Providers.DbMembershipProvider, BlogEngine.Core" 
  24:              passwordFormat="Hashed" 
  25:              connectionStringName="MySQLDB" 
  26:              parmPrefix="?" />
  27:     </providers>
  28: </membership>
  29: <roleManager defaultProvider="DbRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
  30:     <providers>
  31:         <clear/>
  32:         <add name="XmlRoleProvider" 
  33:              type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" 
  34:              description="XML role provider"/>
  35:         <add name="SqlRoleProvider" 
  36:              type="System.Web.Security.SqlRoleProvider" 
  37:              connectionStringName="BlogEngine" 
  38:              applicationName="BlogEngine"/>
  39:         <add name="DbRoleProvider" 
  40:              type="BlogEngine.Core.Providers.DbRoleProvider, BlogEngine.Core" 
  41:              connectionStringName="MySQLDB" 
  42:              parmPrefix="?" />
  43:     </providers>
  44: </roleManager>

Configuration

Once you have these changes made, you can browse out to your web site and you should be greeted by a new welcome message.  Just as with the SQL Server setup, you’ll be missing your widgets.  So you can login with user “admin” and password “admin”.  Add your Administration widget and then refresh your page to see the full menu.

At this point, you should add users and change the admin password.

It really is fairly easy to get set up especially since you can copy and paste the new sections out of my sample web.config.  I also wanted to start that I save a bit of time getting the install script done by starting with the script I found as part of this post by Mr. Wize.  I added the new tables and initial data, but the initial work was done by him.

About

BioPic Hi. My name is Al Nyveldt and I'm a software developer from central Pennsylvania, USA.

I'm on the BlogEngine.NET development team and write on a variety of development related topics. More...

Follow me on Twitter
Contact me via email

Recent Comments

Quote of the Day

"And remember, no matter where you go, there you are."

- Earl Mac Rauch

Sponsor


Recommended Books



Archives


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in